Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Unable to fully disconnect remote sessions when broadcastToPublisher is false #835
In testing I've found that when I disable broadcastToPublisher - which I'd like to do for my application - I'm no longer able to disconnect remote sessions from the BayeuxServer.
I've traced the reason to ServerSessionImpl#disconnect, which removes the session from the server, then attempts to send the disconnect message to the client. However, it uses the same session to do the delivery, which ends up being a no-op because the first condition in ServerSessionImpl#deliver1 triggers.
Ideally there'd be an option to get this to work - potentially by sending the disconnect message from another session on the server. My use case is to disconnect all remote peers from my server based on an application event (in this case, log out from an external system).
I'm including a PR that demonstrates the failure.
pushed a commit
Mar 5, 2019
@nathklei so the issue is more complicated than I expected.
The problem is that a server-side disconnect needs to send an unsolicited message to the client.
However, if the
Keeping around disconnected sessions until the next
If you really need to send a "disconnect" to the clients, it's probably best and more reliable to do this via an application message, and then a client-side disconnect.
I should mention I ended up using a really basic "solution" to the problem in my own code, like
Essentially I always set the flag to true, regardless of what it was set to, then immediately disconnect.
Could we do that internal to disconnect() of ServerSessionImpl? Or are there issues with that approach more generally?