Hello I am working on Node js sockets. I am listening data from multiple devices through ip and port. After running for a while I get this exception and my program stops
events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: read ECONNRESET
    at errnoException (net.js:905:11)
    at TCP.onread (net.js:559:19)
This is the code I have written
var net = require('net');
var request = require('request');
var net = require('net');
var HOST = '172.xx.x.xx';
var PORT = 52xx;
var cluster = require('cluster');
var numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
    // Fork workers.
    for (var i = 0; i < numCPUs; i++) {
        cluster.fork();
    }
    cluster.on('death', function(worker) {
        console.log('worker ' + worker.pid + ' died');
        cluster.fork();
    });
} else {
    net.createServer(function(socket){
         console.log('received connection...');
        socket.on('data', function(data) {
            var options = {
  uri: 'http://demourl/api',
  method: 'POST',
  body: {
    message:data.toString()
  },
  json: true 
};
             console.log(data.toString());
             request(options, function (error, response, body) {
});
        });
    }).listen(PORT, HOST);
}
How can I catch an error and prevent my program from stopping.
 
    