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

Socket.IO Multiple Connections Issue #1

Closed
rgajrawala opened this issue Jul 8, 2014 · 2 comments
Closed

Socket.IO Multiple Connections Issue #1

rgajrawala opened this issue Jul 8, 2014 · 2 comments
Labels

Comments

@rgajrawala
Copy link
Member

Issue

This issue is caused when the development server is restarted when the client is playing the game. The socket shows a disconnected error, and tries to reconnect. When the server is restarted, multiple Connected! messages are fired.

Fix

Emit a shutdown message to all sockets before close. The client will receive this message and then be redirected to a static problem page.

@nise
Copy link

nise commented Oct 17, 2015

Could you explain this with a code sample?

@rgajrawala
Copy link
Member Author

Was properly fixed here: 438a1c1#diff-866d8f7d781501b99d30bc19ed0fe0ed.

Before, I wrapped all the handler bindings in socket.on('connect', ...). Every time the socket connected, it would add the same events. So when a user disconnected and reconnected without leaving the page, multiple events were bound. I moved the handler bindings out of socket.on('connect', ...) so they would only be bound once.

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

No branches or pull requests

2 participants