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

Sockets can`t recreate the session #58

Closed
macedd opened this issue Nov 30, 2014 · 7 comments
Closed

Sockets can`t recreate the session #58

macedd opened this issue Nov 30, 2014 · 7 comments

Comments

@macedd
Copy link

macedd commented Nov 30, 2014

Sometimes on my development process, sails session run out and the app gets broken. Sockets.io do not recreate sessions, so every socket connection get unauthenticated in sails side. This behavior is not seen by the app which do nothing.

The problem is better documented on this comments

I bring the problem to angular boilerplate because the app architecture collaborate for the issue, as sails server is reached only be sockets.

Ill try to match the failed connect within interceptors, but not sure yet how to detect it. Maybe a fix forAuthInterceptor`.

@tarlepp
Copy link
Owner

tarlepp commented Nov 30, 2014

Hmm, this is more a Sails problem. balderdashy/sails#2274

@jstri
Copy link
Contributor

jstri commented Dec 3, 2014

Authentication already relies on JWT tokens in the boilerplate, so I ended up completely disabling sails (express) session, because it caused multiple problems (one example is when user logged out and then tried to register, sails still got session of previously logged out user even if session was destroyed beforehand - logout call to sails api). Also it is recommended to use session less to free up server memory (if external session storage is not configured).
For more information see: http://stackoverflow.com/a/21892112/4261327

@tarlepp
Copy link
Owner

tarlepp commented Dec 3, 2014

@siready Hmm, seems like I cannot disable those sessions like you proposed. Basically if I add config/express.js sails will complain about deprecated configuration file => so no solution.

And if I add that session: null to config/http.js I get following error to console:

error: Trying to save session, but could not determine session ID.
error: This probably means a requesting socket did not send a cookie.
error: Usually, this happens when a socket from an old browser tab  tries to reconnect.
error: (this can also occur when trying to connect a cross-origin socket.)
error: Session could not be persisted: Could not save session.
error: Trying to save session, but could not determine session ID.
error: This probably means a requesting socket did not send a cookie.
error: Usually, this happens when a socket from an old browser tab  tries to reconnect.
error: (this can also occur when trying to connect a cross-origin socket.)
verbose: sending data ack packet
error: Session could not be persisted: Could not save session.

So do you have a working solution for this without warnings and errors?

@tarlepp
Copy link
Owner

tarlepp commented Dec 3, 2014

Also I'm thinking that some of this is in sails core, like that sails PR shows. I just hope that balderdashy guys get that socket.io 1.0 soon to core, so they can merge that PR.

@jstri
Copy link
Contributor

jstri commented Dec 3, 2014

I'll have to check all the changes I made. But I remember it was working straight away without a hassle (added to config/http.js). Also commented out session from 'order' object in the begging of that file. Will try to contribute back as soon as I have some more time. Ah yeah, and I'm not using blueprint actions, so that might be it (balderdashy/sails#841 (comment)).

The only warning I get in production mode is:
"Warning: connection.session() MemoryStore is not designed for a production environment, as it will leak memory, and will not scale past a single process."
Which is really not an issue. There is a ticket about it in sails project: balderdashy/sails#1187

From what I checked session wasn't stored for me, meaning that there isn't any memory problem.

@tarlepp
Copy link
Owner

tarlepp commented Dec 4, 2014

Aah, I'm using blueprints all the way, so maybe that is the problem. So we just have to wait for that PR to fix this properly.

@tarlepp
Copy link
Owner

tarlepp commented Feb 21, 2015

This should be fixed with current version of boilerplate, thanks to sails 0.11.0.

@tarlepp tarlepp closed this as completed Feb 21, 2015
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

No branches or pull requests

3 participants