Nodejs socket connection error

node.js, sockets

Solution

Your code should be ok. `ECONNRESET` means the other side of the socket unexpectedly aborted the connection. It's not your client code causing this error.

See also previous question on the same topic

Problem

I have written this code that sends packet to a socket and reads from it. But when i run it , i get the data from socket but the code throws an error by saying read ECONNRESET. Am I doing anything wrong? ``` var client = net.connect({port:remotePort, host:remoteIpAddress},function(){ client.write(packet); }); client.on('data',function(chunkData){ console.log(chunkData); client.end(); }); client.on('end',function(){ console.log("Reading end"); }); client.on('error', function(err){ console.log("Error: "+err.message); }) ```

Original source

Related problems