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

Can't truly shutdown connection when using close method #29

Closed
j78742 opened this issue Jun 7, 2018 · 12 comments
Closed

Can't truly shutdown connection when using close method #29

j78742 opened this issue Jun 7, 2018 · 12 comments

Comments

@j78742
Copy link

j78742 commented Jun 7, 2018

In my project, I want to shutdown the connection when I leave out. However, no matter the code I passed to close method, it failed, e.g. ," ws.close(1000, 'out')". Why?

@j78742
Copy link
Author

j78742 commented Jun 7, 2018

The connection shutdown at the time and then reconnected!

@lukeed
Copy link
Owner

lukeed commented Jun 7, 2018

What do your event hooks look like? Sockette will terminate if it received 1000 or 1005 code. So I'm thinking there's something inside the event hooks that's preventing that.

@raduciobanu22
Copy link

I got the same issue. Calling close() doesn't seem to close the connection.

@lukeed
Copy link
Owner

lukeed commented Nov 13, 2018

Can you guys try forcing a 1000 code during close?

ws.close(1000)

Also, please let me know what browsers & platforms you are/were experiencing this issue.

Thanks!

@stevesweetney
Copy link

stevesweetney commented Nov 14, 2018

I'm experiencing the same issue on firefox in my react app.
The websocket object closes with code 1006 even when adding

ws.close(1000)

and then it will reconnect.

Also, on 2.0.3 I get unsupported operation error when using the close method

@lukeed
Copy link
Owner

lukeed commented Nov 14, 2018

Thanks, interesting

Are you at all able to post a snippet or reproduction so that I can dig into it? Would love to squash this lingering issue

@marcelschulze
Copy link

Got the same issue with react-native. It will automatically reconnect. @lukeed Do you have any experience with react native? I could provide a minimal setup to run in the ios simulator.

@lukeed
Copy link
Owner

lukeed commented Mar 14, 2019

Sure, thank you. I only hear of this issue with RN, so it seems to be specific to that.

I'll poke thru the repro when you have it :) Thanks

@marcelschulze
Copy link

Sorry for not providing some code... I had a quick look myself right now and it looks like the error code is always 1001, which is not handled in the onclose handler, so it is calling reconnect again.

1001 indicates that an endpoint is "going away", such as a server going down or a browser having navigated away from a page.

1001 is even happening if I do ws.close(1005). Very strange.

@raduciobanu22
Copy link

@lukeed any chance the PR related to this issue gets merged?
Many thanks in advance!

@maxime-guyot
Copy link
Contributor

I'have reverse problem.
With AWS API gateway the connection as gone away after 10 minutes, Sockette receive 1001 code and does not reconnect ... !

@lukeed
Copy link
Owner

lukeed commented Jun 28, 2019

@maxime-guyot sounds like a keep-alive problem. Clients should be pinging the service on an interval shorter than what the server is configured for, or the load balancer in your case.

1001 means something is going away, it doesn't specify client or server. And since every browser will disconnect with a 1001 code when navigating away from the current page, Sockette I can't keep trying to reconnect (since user left)

It's basically a matter of not handling client cleanup correctly versus the server cleaning up idle connections. Sockette can't do both, so it helps out by cleaning up after you and ensuring the client terminates correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants