I have an application composed by a node.js server plus other files and an HTML file. The HTML file is my client, it has to communicate with the node.js server. The node.js server use the objects created with the other node.js files to communicate with a PLC using an ethernet cable. So I've created a socket.io connection between the server and the client and a tcp connection between the server and the PLC.
Now the error: if I start the server and the client with all cables connected I've a correct answer from the PLC, if I disconnect the cable while running I obtain the following error:
events.js:71
throw arguments[1]; // Unhandled 'error' event
^
Error: write EPIPE
at errnoException (net.js:770:11)
at Socket._write (net.js:552:19)
at Socket.write (net.js:511:15)
at Timer.<anonymous> (C:\Users\Massimo\workspace\Scada\plc_driver\fw_driver.
js:289:20)
at Timer.exports.setInterval.timer.ontimeout (timers.js:234:14)
I've already try to manage an error in the server with the code
communication_socket.on('error', function () {
console.log('Error!');
});
I'm running node 0.8.18 and all packages are updated (I've made a npm update -g )
Edit The result of the code
process.on('uncaughtException', function(err) {
console.log(util.inspect(err));
});
is:
{ [Error: write EPIPE] code: 'EPIPE', errno: 'EPIPE', syscall: 'write' }
Any suggestion?
Socket IO errors are not thrown in a way that you can try/catch them. You have to add an on('error', [callback]) handler to each socket. You can read some related discussion about this in Should stream.pipe forward errors? You don't say why you have a Timeout and what socket the timeout is writing to so I can't help you more.
I had this error after a failed deploy command in Metor. I was able to fix it by running the app in debug mode, clicking through the function breakpoints, and then running the deploy script again. I hope this helps someone.