nousername19 0 Newbie Poster

I am running my node.js server by forever and my script gets killed in 1-2 days and i get this error in the log file:

error: Forever detected script was killed by signal: SIGSEGV

Now i have many functions in my node.js script. Upon writing a console.log at the beginning of each function i ended up getting this in the log:

info: transport end (undefined)
debug: set close timeout for client CbU1mvlYaIvDWHB4ChQa
debug: cleared close timeout for client CbU1mvlYaIvDWHB4ChQa
disconnection function
debug: discarding transport
debug: clearing poll timeout
debug: client authorized
info: handshake authorized 2O3m1B3dGWFOJ4W9ChQc
error: Forever detected script was killed by signal: SIGSEGV

the log makes it seem as if either the connect or the disconnect function has a problem, but as the script seg faults after 2 days of running and over 10000 connections/disconnections i think that that might not be really the problem.

Here are my connection and disconnection functions. i also connect to my pgsql database via node-dbi:

var DBWrapper = require('node-dbi').DBWrapper; 
var DBExpr = require('node-dbi').DBExpr; 
var dbConnectionConfig = { host: 'localhost', user: 'user', password:   'pass', database: 'dbname' };
dbWrapper = new DBWrapper( "pg", dbConnectionConfig );
dbWrapper.connect();

io.sockets.on('connection', function(socket) {


  console.log("socket connection");

socket.on('set username', function(userName) {
var milliseconds = (new Date).getTime();
var data = { socketid: socket.id, time: milliseconds };
dbWrapper.insert('all_sockets', data , function(err) {
});

});

socket.on('disconnect', function() {

  console.log("disconnection function");
  dbWrapper.remove('all_sockets', [['socketid=?', socket.id]] , function(err) {} );
 });

});

where could the segment fault be coming from?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.