ECONNRESET Errors in node.js
Socket.io and Express on the same port
The Problem
Running a basic node.js + express + socket.io setup, I would occasionally get ECONNRESET errors. After a bit of trial and error, I found that this seems to have been caused by running socket.io and express on the same port, port 80.
Solution
I opened up port 81 on the server, and ran socket.io through port 81. My code to set things up now looks like:
var httpPort = 80;
var socketIOPort = 81;
var express = require('express');
var app = express();
app.listen(httpPort);
var socketIO = require('socket.io');
var io = socketIO.listen(socketIOPort);
I then had to update the client-side socket.io Javascript to connect on port 81, and so far I've never had these errors since. For reference I'm running node.js v0.10.0, Express v3.3.4 and socket.io v0.9.16.