theturtle32 / WebSocket-Node

A WebSocket Implementation for Node.JS (Draft -08 through the final RFC 6455)
Apache License 2.0
3.76k stars 602 forks source link

Using Unix Socket #255

Open axot opened 8 years ago

axot commented 8 years ago

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)
sseidametov commented 6 years ago

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.