-
Notifications
You must be signed in to change notification settings - Fork 54
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
could not look up session by key: connect.sid #9
Comments
Same issue - please help. |
Maybe because your not passing your secret key to the express session, they need to match I think. edit ...
var SITE_SECRET = 'key'
...
var cookieParser = express.cookieParser(SITE_SECRET)
...
//example express session
app.use(express.session({
secret: SITE_SECRET,
key: 'connect.sid',
httpOnly: true,
store: sessionStore
})); |
That's not needed @eephillip, can you guys @githubpendosoft and @aliw77 copy and paste your output of npm ls? |
That looks ok, however I reviewed your code and am not sure whether this is ok:
Can you follow the instructions from socket.io docs on how to load the client? |
I'm afraid I can't. After I've installed the socket.io with "npm install socket.io" how it is described on their site I have the socket.io.js in these fields only ./node_modules/socket.io/lib/socket.io.js And if I use the code from their example of course I can add some rewrite rules to htaccess but I think it will have the same affect as if I change the path to script. ......... May be it will work if I set up it to listen the port 80 but I can't do it since I have to have the Apache run on this port. PS. sorry for my English. |
Yes, this is preferable
This should also be fine without hostname and port, assuming you're browsing within the same context. I just merged a pull request that will give you an error object with better tracing. It's published on npm as 0.1.4. Can you update it, try again and paste the stack trace? |
I've added the "handshake" data to log: sessionSockets.on('connection', function (err, socket, session) { So the output is: info - socket.io started |
same problem here. so i tried other packages, the same problem. like githubpendosoft, the cookies were empty/null. then i came across this socketio/socket.io#776, yipingshui's comment on 'use io.connect("http://ip:port")', bingo! my original: io.connect("http://192.168.10.1:2222") newbie here, my guess:
|
Thanks quiricada. Can you githubpendosoft follow up on that and let us know if you make any progress? It doesn't look like you're doing something wrong with session.socket.io, it seems to be something with your socket.io config. |
I've used io.connect('http://localhost:8008'); as you can see in the code I've posted above. I've got the same error: info - socket.io started The code I will try to test it on real domain and let you know in 1-2 days. |
Wait, you're using socket.io with php on apache? This library won't help you. It integrates socket.io with either connect or express which are node modules. |
I'm use socket.io with nodejs server. It doesn't working without Apache as well. Please check my code. Is it correct? server: http://myxomop.e-vds.ru/node/app2.js Could you please provide me with en example that is working? BR. |
Ok, I wrote one quickly, doing the minimum to demo the features: read and write session values within sockets. It's under /example. You will need to do npm install & node server.js, then go to localhost:3000. Hope that helps. |
Absolutely great module. Thanks for writing it. I am up and running now. I had some issues with session being undefined and it was because on client side I connected using 'http://127.0.0.1:3000' but had browsed to 'http://localhost:3000'. Error was '{}'. It would be cool if you could detect this issue and report it in err. |
Thanks for your feedback bjwyse. That's a common mistake when getting started with socket.io, and you can avoid that by simply calling io.connect() without an address. |
Hi, I'm still having this problem. so it can't be the same problem of bjwyse. |
@MaxMarkson can you try the example and see if that works out there? https://github.com/functioncallback/session.socket.io/tree/master/example |
When I try the example I have this error: But I don't have to use the express module, I need an integration between connect, connect-route, socket.io and passport. |
@functioncallback have you got any news about the problem? |
@MaxMarkson I don't see any problem really. I have a more complete working example here: https://github.com/functioncallback/upstream Take a look and see if that helps maybe? At least passport is being used, with express, socket.io and other modules. Also, it's deployed here: http://upstream-beta.herokuapp.com |
This error "could not look up session by key: connect.sid" appeared only in chrome(but not every time to fix you have to restart the browser ), firefox works ok. |
Well, I have the problem even with firefox and the server.listen was already after the on connection. |
Hello! first of all thanks for this great code, but i've been with a problem for some hours and i guess maybe you can help me with it.. I'm a newie with nodejs and express, this is my server code (i got it from the sample): var http = require('http') var cookieParser = express.cookieParser('aaaa') app.configure(function () { app.use(express.bodyParser()); var server = http.createServer(app) var SessionSockets = require('session.socket.io') app.get('/', function(req, res) { sessionSockets.on('connection', function (err, socket, session) { socket.on('foo', function(value) { server.listen(3000); and this is the client code: <script type='text/javascript' src='socket.io.js'> </script> <style> body { padding: 30px 50px; }
SessionSockets usage example
The problem is that the session is always null when it reachs the server. The error that comes with it is "Error: could not look up session by key: connect.sid" I think i had it working one time but after i can't configure it to do it. I'm getting crazy with this error and i can't find a solution. Any help will be much apreciated, Thanks in advance! Hugo. |
Hi :) i have the same problem :( :D |
Hi, I had the same problem as bjwyse, and his solution worked for me |
Same problem with express4 and all new deps. |
I can't make it working.
The client connected but the session always is undefined with error:
could not look up session by key: connect.sid
Could you help please?
app.js
var http = require('http')
, connect = require('connect')
, express = require('express');
var app = express()
, cookieParser = express.cookieParser('key')
, sessionStore = new connect.middleware.session.MemoryStore();
app.configure(function () {
//hiding other express configuration
app.use(cookieParser);
app.use(express.session({ store: sessionStore }));
});
var server = http.createServer(app)
, io = require('socket.io').listen(server);
var SessionSockets = require('session.socket.io')
, sessionSockets = new SessionSockets(io, sessionStore, cookieParser);
server.listen(8080);
sessionSockets.on('connection', function (err, socket, session) {
console.log('connection ERR ', err);
console.log('connection session ', session);
});
client
<html>
<head>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' ></script>
<script src='./node_modules/socket.io/node_modules/socket.io-client/dist/socket.io.js'></script>
<script>
var iosocket = null;
$(function(){
iosocket = io.connect('http://localhost:8080');
iosocket.on('error', function (reason){
console.error('Unable to connect Socket.IO', reason);
});
iosocket.on('connect', function () {
$('#status').html('Connected');
});
iosocket.on('disconnect', function() {
$('#status').html('Disconnected');
iosocket.socket.connect();
});
});
</script>
</head>
<body>
<div id='status'></div>
</body>
</html>
The text was updated successfully, but these errors were encountered: