Tutorial 9: Node.js common Error 2 : Unknown system errno 114

If you have used sockets in your node.js project,  you might have seen a error

Unknown system errno 114

This error occurs because you are trying to use a socket which is already busy with another connection.

What caused it?

You might have defined the socket globally and calling the functions that use the socket simultaneously.
something like
var socket1 = new net.Socket();
...
..
exports.func1=function(){
socket1.connect (PORT, HOST, function() {
            socket1.end('some command');
        });
};

exports.func2=function(){
socket1.connect (PORT, HOST, function() {
            socket1.end('some command');
        });
};

When you call func1 and func2 simultaneously func2 try to use socket1 which is already busy in func1.


Solution:
define socket in new function so that if both function gets called simultaneously two socket will be create or you can create something like generic pool to address this issue
https://github.com/coopernurse/node-pool

Comments

Popular posts from this blog

Tumblr posts about sexplanation, DoeEyes and Dr. Lindsay Doe

बैगन

Type of Common Charts used in visualization