use websockets module's connection collection, makes things much easier. see https://npmjs.org/package/nodejs-websocket