Skip to content
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

It's not possible to abort an opening websocket connection #205

Open
yerfinojul opened this issue Sep 10, 2016 · 4 comments
Open

It's not possible to abort an opening websocket connection #205

yerfinojul opened this issue Sep 10, 2016 · 4 comments

Comments

@yerfinojul
Copy link
Contributor

It's possible to reproduce this situation setting a connectTimeout to something like 15 seconds.
If the server is unresponsive for some reason and this timeout is reached, then there is no way to close this connection, which could be established anyway after the timeout is reached, calling close() or unsubcribe() has no effect because of this code:

                    if (_websocket.canSendMessage) {
                        _debug("invoking .close() on WebSocket object");
                        _websocket.close();
                    }

So, bottom line, you end up with a useless connection that you cannot close.
I think it should be possible to call close() as long as the readyState is 0 or 1 (OPENING or OPEN).
Is there a real reason to do that "if" ?
According to the websocket spec when "the WebSocket connection is not yet established [WSP]
Fail the WebSocket connection and set the readyState attribute's value to CLOSING (2). [WSP]"

NOTE: to simulate an unresponsive server you can just use netcat, e.g. on mac:

nc -l  9999

Thanks

@yerfinojul
Copy link
Contributor Author

@jfarcand any updates on this issue ?

@jfarcand
Copy link
Member

@yerfinojul Contribution welcomed...I have zero time to work on this for the next couple of months :-)

yerfinojul pushed a commit to yerfinojul/atmosphere-javascript that referenced this issue Mar 29, 2017
@yerfinojul
Copy link
Contributor Author

@jfarcand pull request created, I don't see any problems in my tests but you might know better than me.

@jfarcand jfarcand closed this as completed Nov 8, 2018
@danielgrad
Copy link

@jfarcand I see the issue is closed, but not solved (above PR has never been merged). is there a plan to fix this?

@jfarcand jfarcand reopened this Nov 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants