nchan
nchan copied to clipboard
unsubscribe not reaching upstream
With this configuration
` location ~ /sub/(.+)$ { nchan_channel_id $1; nchan_subscribe_request /upstream/sub; nchan_unsubscribe_request /upstream/unsub; nchan_subscriber; }
location = /upstream/unsub {
proxy_pass http://127.0.0.1:9292/unsub;
proxy_ignore_client_abort on; #!!!important!!!!
proxy_set_header X-Subscriber-Type $nchan_subscriber_type;
proxy_set_header X-Channel-Id $nchan_channel_id;
proxy_set_header X-Original-URI $request_uri;
}
location = /upstream/sub {
proxy_pass http://127.0.0.1:9292/sub;
proxy_set_header X-Subscriber-Type $nchan_subscriber_type;
proxy_set_header X-Message-Id $nchan_message_id;
proxy_set_header X-Channel-Id $nchan_channel_id;
proxy_set_header X-Original-URI $request_uri;
}
location ~ /pub/(.+)$ {
nchan_publisher;
nchan_channel_id $1;
}`
var source = new EventSource('http://localhost:8001/sub/subscribe/hokuto:20000/test/device/1/double_scalar');
is correctly forwarded to location upstream/sub
but
source.close()
does not trigger an unsub (nothing is actually delivered to http://127.0.0.1:9292 upon source.close() )
Expected behaviour:
source.close() should be notified upstream
Nobody has an idea of where I am wrong?
@delleceste https://nchan.io/#subscriber-presence says:
Note that the subscribe/unsubscribe hooks are disabled for long-poll and interval-poll clients, because they would trigger these hooks each time they receive a message.
Those callbacks are for WS connections only, I think.
We had to build longpoll presence feature separately, based on a timer and expiring keys in redis.