I have a nodejs / express app that uses winston with a udplogger. It works fine on a number of development environments, including Linux (Fedora, Centos), OSX and various versions of Windows.
We have just tried to run the app on Windows 8 for the first time, and are not able to run it.
dgram.js:163
throw new Error('Socket is already bound');
Error: Socket is already bound
at Socket.bind (dgram.js:163:11)
at UdpLog.connect (\path\to\node_modules\mod_name\lib\winston-udplog.js:147:24)
winston-udplog.js, L47:
return this.socket.bind();
The application initializes a UDP logger (from a customised version of this: https://github.com/indexzero/winston-syslog/blob/master/lib/winston-syslog.js):
// Initializing the socket...
this.socket = new dgram.Socket("udp4");
// Sending the message... host=localhost, port=514
var buffer = new Buffer(someMsg);
if (buffer.length > 0) { self.socket.send(buffer,0,buffer.length,self.port, self.host, onError);
I have checked netstat -an and there are no UDP listeners on UDP 514 (although the code works if there is a listener on udp:localhost:514 on other systems), so am pretty lost as to why the application is crashing.
any ideas as to why the app is crashing? If I remove the UDP listener from the winston configuration, it works fine.
thanks