javascript - Node.js / Socket.io raising Error at TCP.Onread -
i'm running simple node instance pushes data redis clients through socket.io.
my node server crashes time time. , i've spend hours in debugging, can't find problem.
it not predictable. instance runs fine 36 hours, sometime crashes every minute.
i receive following error message:
events.js:77 throw er; // unhandled 'error' event ^ error: read econnreset @ exports._errnoexception (util.js:676:11) @ tcp.onread (net.js:529:26)
this code:
var http = require('http'); var server = http.createserver().listen(4000); var io = require('socket.io').listen(server); var redis = require('socket.io/node_modules/redis'); var sub = redis.createclient(); var sc = redis.createclient(); //active socket counter //subscribe redis chat channel sub.subscribe('chat'); sub.subscribe('total_spots'); io.sockets.on('connection', function (socket) { //grab message redis , send client sub.on('message', function(channel, message){ socket.send(message); }); count++; sc.incr("sockets"); socket.on('disconnect', function(socket){ count--; sc.decr("sockets"); }) socket.on("error", function(err){ console.log(err); console.log("error"); }); });
i appreciate tipps or ideas.
thanks!
Comments
Post a Comment