emitter-io / emitter

High performance, distributed and low latency publish-subscribe platform.

Home Page:https://emitter.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Disconnected clients remain on presence calls/no unsubscribe event fired on disconnect

IliasP91 opened this issue · comments

commented

The following bug is still present on the latest and potentially edge docker build of emitter:
cf93d22

When a client disconnects from a channel an unsubscribe message is not dispatched and the presence status requests return a list that includes the disconnected clients.

I think that might be a different issue, the other bug was about when an entire peer goes down. Normal presence should work as expected. @Florimond could you verify?

@IliasP91 I was about to say it works properly according to my tests both on latest and edge as well as by running Emitter in VS Code. Then I managed to reproduce the issue once on docker lastest, but never again. Do you have a way to reproduce the issue consistently?

commented

hi guys, ill try to create a small solution that reproduces the issue, ill keep you updated

commented

hmm very interesting, just created a demo proj and attempted to recreate this, it worked fine as v2.8 whereas before it was not raising an unsubscribe event if I just closed a client console app. Now it does. Could it be that something has changed in the last 2 weeks on the latest branch/docker build?

Regardless here are the repro steps and the demo repo:
https://github.com/IliasP91/emitter-io-subscription-issue-repro

Repro steps:
Create a new docker instance with the latest image
docker run -d --name emitter-latest -p 8080:8080 -e EMITTER_LICENSE=PfA8IEfJReKdp2pWUOw_MVsWWUsaPdPhV79_C75M85nEsaz3ECnmNla4j_G8Ph8dkLpJkSH-5sqjDrG13OMLAQ:3 --restart=unless-stopped emitter/server:latest

Create a read,write,presence key on the new instance for channel 'test/'
Copy key to both console apps

Build and run Run.bat

Close one of the 5 opened clients
Type something on the broadcaster and press enter to invoke a presence request and see the list of connected clients

Feel free to close this if you think it doesnt require further investigation

I reproduced a similar behavior when I subscribe twice to the same channel with the same client. There is a counter that is incremented twice, and the other clients are only notified of a disconnection if this counter is at 0. But since, by exiting the program, you only produce one disconnection event, the counter is still greater than 0, and the other clients are never notified.

I'll discuss the issue with @kelindar to make sure I understand what was the intention behind this piece of code and fix it properly.

@IliasP91

This commit should fix your issue: 9e628aa

Don't hesitate to test and confirm the fix. Closing the issue for now.