tj / axon

message-oriented socket library for node.js heavily inspired by zeromq
MIT License
1.5k stars 155 forks source link

Binding to UNIX sockets results with RangeError #156

Closed METACEO closed 6 years ago

METACEO commented 8 years ago

Using the first two examples (edited below) with axon v2.0.2 I replaced the port number 3000 with a UNIX socket path. 'unix://'+__dirname+'/axon.socket' will complete to unix:///axon_test/axon.socket

receiver.js

var axon = require('axon');
var sock = axon.socket('pull');

sock.connect('unix://'+__dirname+'/axon.socket');

sock.on('message',(msg) => console.log(msg.toString()));

pusher.js

var axon = require('axon');
var sock = axon.socket('push');

sock.bind('unix://'+__dirname+'/axon.socket');

console.log('push server started');

setInterval(() => sock.send('hello'), 150);

I end up with the following...

[root@centos7 axon_test]# node receiver.js
net.js:924
      throw new RangeError('port should be >= 0 and < 65536: ' + port);
      ^

RangeError: port should be >= 0 and < 65536: NaN
    at lookupAndConnect (net.js:924:13)
    at Socket.connect (net.js:901:5)
    at Socket.connect (net.js:862:37)
    at PullSocket.Socket.connect (/axon_test/node_modules/axon/lib/sockets/sock.js:294:8)
    at null._onTimeout (/axon_test/node_modules/axon/lib/sockets/sock.js:279:12)
    at Timer.listOnTimeout (timers.js:89:15)
[root@centos7 axon_test]#

...the pusher.js will run all the way through.

kessler commented 8 years ago

@METACEO Ran into the same issue. In my case this only happened if my equivalent of your pusher was not running before the receiver attempted to connect.

datvong-wm commented 6 years ago

Same as #168

METACEO commented 6 years ago

@datvong-wm thanks, I'll close this issue out with your proposed PR.