tj / axon

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

Error on connect for sub socket #143

Open adicirstei opened 9 years ago

adicirstei commented 9 years ago

Hi, I tried the code sample in the README for pub/sub sockets and got the EADDRNOTAVAIL error. Any Idea why this is happening? I am using a windows 7 64 bits machine with node 0.12.2 for the last test. I also got the same error on node 0.10.38 but only once a then the process died. I ran this in the node REPL. The pub part was working just fine in a different REPL, no error occured (just to know that I didn't forgot that part).

> var a = require('axon')
undefined
> var s = a.socket('sub')
undefined
> s.connect(3003)
{ opts: {},
  server: null,
  socks: [],
  settings:
   { hwm: Infinity,
     identity: '120752',
     'retry timeout': 100,
     'retry max timeout': 5000 },
  subscriptions: [],
  type: 'client' }
> Error: connect EADDRNOTAVAIL
    at exports._errnoException (util.js:746:11)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1000:19)
> Error: connect EADDRNOTAVAIL
    at exports._errnoException (util.js:746:11)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1000:19)
jcrugzz commented 9 years ago

@adicirstei does this still happen on 0.10.x? Something may have changed in 0.12.x/iojs that need to be handled or there is a bug in 0.12.x. Could you test this in a script independent of the repl and post the code in a gist that reproduces this issue? Thanks!

adicirstei commented 9 years ago

I did this on node v0.10.38:

image

The gist contain just the README code: https://gist.github.com/adicirstei/1cd7d4888a91c39a466b

It doesn't matter if I'm running 32 or 64 bit versions of node. The outcome is the same. Also, please note that I am using the axon v2.0.1. I'll try an older one.

adicirstei commented 9 years ago

Good news!

If I connect on a specific address it is working just fine. The bind part stayed the same.

  sock.connect(3000, '127.0.0.1');

Maybe on windows, trying to connect to '0.0.0.0' is not such a good idea.

jonathanrdelgado commented 9 years ago

@adicirstei You saved me some troubleshooting with that fix, thank you!