Reputation: 51
Keep getting this warning & error when I lift my app and can't figure it out. Hoping someone has an idea about this:
warn: Socket disconnected, but session could not be loaded to pass to configured disconnect handler:
sails.config.sockets.onDisconnect()
. Will pass a fake, empty session as argument to lifecycle callback. Details: Error: Session could not be loaded at _createError (/Users/JAT/Dropbox/Bottage/bottage_app/node_modules/sails/lib/hooks/session/index.js:271:21) at Immediate._onImmediate (/Users/JAT/Dropbox/Bottage/bottage_app/node_modules/sails/lib/hooks/session/index.js:274:13) at processImmediate [as _immediateCallback] (timers.js:358:17) { [Error: Session could not be loaded] code: 'E_SESSION' }
wZVanG Edit: The problem is already fixed, however I wonder if I have the correct configuration:
sailsrc (I removed the models from Sails
created by default because I just use mongoose
), However the sockets
I did not have to remove them:
"hooks": {"orm": false, "pubsub": false, "blueprints": false}
/config/sessions.js
adapter: 'mongo',
host: 'localhost',
port: 27017,
db: 'page',
collection: 'sessions',
This stores it in my Mongo database:
{
"_id" : "Nt90RxTcHkOT9aM3qJ1QzxyHlnvFoUuw",
"session" : "{\"cookie\":{\"originalMaxAge\":null,\"expires\":null,\"httpOnly\":true,\"path\":\"/\"},\"passport\":{}}",
"expires" : ISODate("2015-07-24T10:59:42.551Z")
}
It is correct?
Upvotes: 5
Views: 3547
Reputation: 3068
The reason for the message is that when you restart sails the session info is deleted on the server side but the client side still has a session cookie and when it reconnects it reuses the previous session cookie to identify which is no longer valid and therefore the server logs this warning.
There are a number of ways to prevent this message:
assets/js/dependencies/sails.io.js
and sails.io.js include file in tasks/pipeline.js
and for the server side add this to .sails.rc
:
{
"hooks": {
"sockets": false,
"pubsub": false
}
}
Upvotes: 1