nchan icon indicating copy to clipboard operation
nchan copied to clipboard

unsubscribe not reaching upstream

Open delleceste opened this issue 4 years ago • 2 comments

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

delleceste avatar May 02 '20 17:05 delleceste

Nobody has an idea of where I am wrong?

delleceste avatar May 07 '20 07:05 delleceste

@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.

ivanovv avatar May 17 '20 15:05 ivanovv