Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js EPIPE error

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?

like image 883
Max Markson Avatar asked Feb 05 '13 08:02

Max Markson


People also ask

What is an Epipe error?

https://nodejs.org/dist/latest-v12.x/docs/api/errors.html. EPIPE (Broken pipe): A write on a pipe, socket, or FIFO for which there is no process to read the data.

What is Enoent error in Nodejs?

The code ENOENT means that npm fails to open a file or directory that's required for executing the command. The npm start command is used to run the start script in the package. json file.25-Jun-2022.

What is error first callback in node JS?

Error-First Callback in Node. js is a function which either returns an error object or any successful data returned by the function. The first argument in the function is reserved for the error object. If any error has occurred during the execution of the function, it will be returned by the first argument.


1 Answers

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.

like image 154
Old Pro Avatar answered Sep 20 '22 22:09

Old Pro