-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebSocketSubject fails to recreate socket when close isn't immediate #4650
Comments
I see you put a lot of effort into this reproduction. Thank you for that. I'm a little strapped for time to dig into this, but on the surface, I'm concerned that this might be behaving as intended, as it's supposed to buffer messages until the new socket is open. 🤔 |
My use case here is I have 2 tabs in a UI, when I change tabs I unsubscribe to a stream, which starts to close the connection. The new tab makes a different subscribe but this fails as as the close isn’t complete. My current work around is to delay new subscriptions by 250ms, but this is really dependant on how long the connection takes to close. |
I bump into exact same thing with similar use case ( switching between two routes ). Agree that the delay work around works and dependant on how long the connection takes to close. I borrow @markmcdowell stackblitz to reproduce how its works when set to 1s. |
any luck with this? |
@benlesh @cartant I am also having the exact same issue. Basically, what seems to be happening is that the flow of the WebsocketSubject closing and reconnecting sockets is very dependent on the JavaScript stack. In my case, we are subscribing and unsubscribing during an Angular route change. After doing a deep dive into the WebsocketSubject, here is what is happening.
I have been considering different approaches to fixing this. One would be to have some kind of buffer count that gets incremented when the multiplex method is called which then is checked on line 369 before the socket is closed and reset. This would allow that code to know if there were any new subscriptions to be staged. Another approach to fixing this might be to set a property on the class (like What do you think? I am happy to make a PR for either of these solutions or a solution that you propose. |
Any update on this as an issue? I have had to implement both solutions in my code to fix the issues outlined in my post above. |
I ran into the same issue and I also used this fix to solve my problem. |
The close event on WebSocket does not always occur immediately after running the close function. If the close event is occurs after a new WebSocket is opened, then the reset needs to be skipped. This checks to make sure the socket being reset is the one that matches the event. Closes ReactiveX#4650, ReactiveX#3935
The close event on WebSocket does not always occur immediately after running the close function. If the close event is occurs after a new WebSocket is opened, then the reset needs to be skipped. This checks to make sure the socket being reset is the one that matches the event. Closes #4650, #3935 Co-authored-by: Mark Knapp <mknapp@leightronix.com>
The close event on WebSocket does not always occur immediately after running the close function. If the close event is occurs after a new WebSocket is opened, then the reset needs to be skipped. This checks to make sure the socket being reset is the one that matches the event. Closes #4650, #3935 Co-authored-by: Mark Knapp <mknapp@leightronix.com>
Bug Report
Current Behavior
If the close of a websocket takes a little bit of time subsequent calls to multiplex fail to send any subscription messages and close the socket immediately. See reproduction below.
Reproduction
Expected behavior
A new call to multiplex should subscribe and stay open.
Environment
The text was updated successfully, but these errors were encountered: