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

Clarify reconnection details in documentation #308

Closed
ccoors opened this issue Jun 21, 2019 · 1 comment
Closed

Clarify reconnection details in documentation #308

ccoors opened this issue Jun 21, 2019 · 1 comment
Assignees

Comments

@ccoors
Copy link

ccoors commented Jun 21, 2019

I just had to read code because I wanted to know what happens to the session data when a client reconnects. It turns out that a client gets a new sid on reconnect and the session data is lost.

The server can maintain application-specific information in a user session dedicated to each connected client. Applications can use the user session to write any details about the user that need to be preserved throughout the life of the connection, such as usernames or user ids.

Maybe add a sentence like "Please note that in the event of a disconnect the session is deleted and lost even if a reconnect occurs, because the client will receive a new sid."

Additional quesiton:
So if I would like, for example, save the 'logged-in' state of a client in my server I would have to save that "out of band" and manage my own client IDs? So adding a whole protocol layer on top of Socket.IO? Or is there a more idiomatic way of doing it?

@miguelgrinberg
Copy link
Owner

Each time there is a disconnection and re-connection your disconnect and connect handlers will be invoked. So from the server's side this would look exactly like a client that went away and then returned. Authentication needs to be done again, and if you were storing data in the session that data needs to be regenerated.

I agree that this should be mentioned in the docs.

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

2 participants