nchan_eventsource_event Event source Event type
Seems I'm not able to set the event type on my sse events, when I publish a new event.
post request to publish httpx.post( f"http://localhost:8001/pub?chanid={chanid}&type={event_type}", data={"message": "new_comment", "event": "new_comment"}, )
nginx configuration
server {
listen 8001;
server_name outtaofficed;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
proxy_pass http://127.0.0.1:8000;
}
location = /events {
nchan_subscriber;
nchan_channel_id $arg_chanid;
add_header 'Access-Control-Allow-Credentials' 'include';
}
location = /pub {
nchan_publisher;
nchan_channel_id $arg_chanid;
nchan_eventsource_event $arg_type;
}
}
what i'm getting in the browser
1598574438:0 | $arg_type ```
Hi,
I run into the same problem. I solved it by setting the header to X-EventSource-Event:fooevent for the publisher, which somehow works. I didn't get it working with $arg variable or other variables from nginx.
I'm not sure if this is a bug, or we both configure it wrong.
Bump, CC: @slact. Seems the problem here is that the nchan_eventsource_event directive doesn't expand variables. For example,
nchan_eventsource_event "$nchan_channel_id";
Returns the message,
event: $nchan_channel_id
id: 1615759869:0
data: {hi: 'mom'}
Instead of the expanding the nginx variable.
Not a C or nginx expert, but I'm thinking the value needs to be evaluated for variables, perhaps something along the lines of treating the string for nchan_eventsource_event as an "nginx complex value"?