Session sharing between Websockets and HTTP

39 views
Skip to first unread message

Weber A.

unread,
Apr 21, 2015, 8:52:28 AM4/21/15
to socket...@googlegroups.com
Hi,

we are sharing sessions between websocket and HTTP requests.

We see that in HTTP requests the connect.sid gets processed by cookie-parser and validated but during the websocket connection cookie-parser is not called.

The result is that the HTTP request sees a session ID like this:

UlTp92sLseIuSepPWpJr6RLPOip-SdBI

and the corresponding websocket session ID looks like this:

s%3AUlTp92sLseIuSepPWpJr6RLPOip-SdBI.z6gbo9fzFjCewBMPeoH4jen1ZgZOG7A0FQ2ZyVvsJgQ

This leads to problems as they are two separate sessions in the session store.

How can we solve this problem?

Thank you,
   Andreas

Weber A.

unread,
Apr 21, 2015, 10:25:41 AM4/21/15
to socket...@googlegroups.com
Small update:

we use connect-route for routing our HTTP requests. I've appended a middleware before the connect-route middleware to add session information to the request object.

To get the correct session, I do the following:

var sessionId = encodeURIComponent('s:'+signature.sign(req.session.id,socketstream.session.options.secret));
socketstream.session.find(sessionId, null, function(session) {


Is this the intended way to do this?

Henrik Vendelbo

unread,
Apr 28, 2015, 8:29:16 AM4/28/15
to socket...@googlegroups.com
I think we need to look closer at this. If you are on GitHub feel free to post an issue with this information.


On Tuesday, April 21, 2015 at 2:52:28 PM UTC+2, Weber A. wrote:
Reply all
Reply to author
Forward
0 new messages