Error: Socket is not writable in Node.JS

I have a simple tracking application running on Node.JS that basically parses the URL it sets and returns a 1x1 pixel gif image. Several times a day, I get the following error in the log:

Error: Socket is not writable at Socket._writeOut (net.js:391:11) at Socket.write (net.js:377:17) at ServerResponse._writeRaw (http.js:392:28) at ServerResponse._send (http.js:372:15) at ServerResponse.write (http.js:622:16) at ServerResponse.end (http.js:682:16) at /var/www/app.js:221:7 at Server.<anonymous> (/var/www/app.js:234:3) at Server.emit (events.js:67:17) at HTTPParser.onIncoming (http.js:1124:12) 

I have absolutely no idea what causes this. Any ideas where to look? (this happens on different UAs, although so far I have only seen this when the request comes from a Windows machine, but given that the vast majority of computers are Windows, this does not mean anything).

+4
source share
2 answers

You must indicate the error https://github.com/joyent/node/issues?state=open

This may be a violation of the usual protocol for recording a stream in your module or in the HTTP module of the system: if write () does not work, wait for the drain () event. Therefore, you need to look for unsuccessful entries in your code and the HTTP javascript module compiled into the binary / usr / bin / node and double-check that the waiting expectations are met. Drain events are rare, so it is possible that this error was undetected for a long time.

+1
source

This problem has been addressed since it is actually related to how you use the pool (using the connection from the pool even after it has been closed).

The fix is ​​to use client.pauseDrain () to reuse a single connection in the pool.

Additional information, and the source for this answer is here .

+1
source

All Articles