Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for unix sockets #984

Open
thejhh opened this issue Jul 31, 2016 · 5 comments
Open

Support for unix sockets #984

thejhh opened this issue Jul 31, 2016 · 5 comments
Labels
enhancement New feature or request

Comments

@thejhh
Copy link

thejhh commented Jul 31, 2016

Websockets has a support for unix sockets with a url like ws+unix:///path/to/file, but Socket.io doesn't seem to support it.

The server:

const path = './server.sock';

var app = require('http').createServer(function(req, res) {
    console.log('Request for ' + req.url);
    res.statusCode = 200;
    res.setHeader('Content-Type', 'text/plain');
    res.end('Hello World\n');
});

var io = require('socket.io')(app);

io.on('connection', function (socket) {
    socket.emit('news', { hello: 'world' });
    socket.on('my other event', function (data) {
        console.log(data);
    });
});

app.listen(path, function() {
    console.log(`Server running at ${path}`);
});

...and client:

const path = './server.sock';
var socket = require('socket.io-client')('ws+unix://' + require('path').resolve(path));
socket.on('connect', function(){
        console.log('connect');
});
socket.on('event', function(data){
        console.log('event: ', data);
});
socket.on('disconnect', function(){
        console.log('disconnect');
});

...but client doesn't connect...

@emcniece
Copy link

Have you switched to a different library since posting this?

@thejhh
Copy link
Author

thejhh commented Oct 18, 2016

Who? Me?

@emcniece
Copy link

Yes @jheusala - just wondering if you solved this problem somehow or dropped it.

@thejhh
Copy link
Author

thejhh commented Oct 19, 2016

No, I haven't solved it. I recall I just used normal HTTP network as a workaround. I would indeed use UNIX sockets if it were possible, and AFAIK there is no reason why it couldn't work. Unix sockets give better security since you can use simple file system permissions to control who has access to the service.

@thoqbk
Copy link

thoqbk commented Apr 23, 2019

@darrachequesne do you think it's worth to have a fix for this? I can work on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants