I have the following node.js code running well, but I cannot seem to get console.log
to execute - what could the reason be? The redis
is in scope and the redis.get()
works fine in an earlier location (so I know the syntax is fine).. The console.log that does not execute is commented with the line "# cannot execute this line" in the code. Would be grateful for any pointers on how to debug..
The program prints out 'pong' and 'pong2', so I know it is responding to a ping.
var WebSocketServer = require('ws').Server
var wss = new WebSocketServer({
port: 8080
});
var redis = redis_server.createClient(6379, 'localhost');
wss.on('connection', function(ws) {
ws_auth(redis, ws, function(authresult, uid) {
if (!authresult) {
ws.close();
return;
}
ws.on('ping', function() {
console.log('pong')
var cookie = ws.upgradeReq.headers.cookie;
cookie_json = JSON.parse(cookie);
redis.get('session:' + cookie_json.sessionid, function(err, value) {
console.log(getDateTime() + ': value ' + value + " session exits");#cannot execute this line
});
ws.pong();
console.log('pong2')
});
});
});