WebSocket-Node
WebSocket-Node copied to clipboard
Using Unix Socket
We use Nginx as a reverse proxy to websocket.
nginx.conf
proxy_pass http://unix:/path/to/file.sock:/;
nodejs code
var httpServer = http.createServer( httpHandler );
fs = require('fs');
sock="/path/to/file.sock";
fs.unlink(sock);
httpServer.listen( sock ,function() {});
var ws = new WebSocket({
httpServer: httpServer,
autoAcceptConnections:true
});
ws.on('connect', websocketConnectHandler);
This basically works fine, but sometime write EPIPE will occurs and this causes server stop.
events.js:154
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at exports._errnoException (util.js:856:11)
at WriteWrap.afterWrite (net.js:767:14)
Yes, it is important also for server across server environment. I also not follow how to join client to UNIX-socket. It might be great option. I will try now to do that.