node-tcp-hole-punching icon indicating copy to clipboard operation
node-tcp-hole-punching copied to clipboard

Client B throw Error: listen EADDRINUSE

Open 131 opened this issue 9 years ago • 6 comments

So, i think my setup is okay, yet, clientB crash Error: listen EADDRINUSE 172.19.21.58:34662

ClientA is like

R:\node-tcp-hole-punching>node clientA.js
> (A->S) connecting to S
> (A->S) connected to S via 192.168.131.19 65066
> (A->S) response from S: {"name":"A","localAddress":"192.168.131.19","localPort":65066,"remoteAddress":"::ffff[something],"remotePort":65066}

> (A) 192.168.131.19:65066 ===> (NAT of A) ::ffff:[something]65066 ===> (S) [somethingelse]:9999

> (A->S) response from S: {"name":"B","localAddress":"172.19.21.58","localPort":34662,"remoteAddress":"::ffff:[BPublicIP]","remotePort":34662}
> (A) time to listen on port used to connect to S (65066)
> (A->B) connecting to B: ===> (B) ::ffff:[BPublicIP]:34662
> (A) listening on  192.168.131.19:65066
> (A->B) connection closed with err: ETIMEDOUT
> (A->B) connecting to B: ===> (B) ::ffff:[BPublicIP]:34662

clientB is like

> (B->S) response from S: {"name":"A","localAddress":"192.168.131.19","localPort":65066,"remoteAddress":"::ffff:[clientAPublic]","remotePort":65066}
> (B) time to listen on port used to connect to S (34662)
> (B->A) connecting to A: ===> (A) ::ffff:[clientAPublic]:65066
events.js:141
      throw er; // Unhandled 'error' event

Is there something i can try ?

131 avatar Nov 23 '16 23:11 131

Are you an mac or on windows? (or linux)?

SamDecrock avatar Nov 28 '16 07:11 SamDecrock

Client A is windows, client B linux (both with node 4.5)

131 avatar Nov 28 '16 13:11 131

The same error with me ClientA is on Windows, ClientB is on Linux

If ClientA is behind NAT, ClientB has public IP, this will affect the result?

birbird avatar Dec 13 '16 16:12 birbird

I don't think its possible to listen on the same port in Windows.

2016-12-13 17:55 GMT+01:00 birbird [email protected]:

The same error with me ClientA is on Windows, ClientB is on Linux

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/SamDecrock/node-tcp-hole-punching/issues/2#issuecomment-266794610, or mute the thread https://github.com/notifications/unsubscribe-auth/AAhmVw67S2wJza_uynRSJEMusNaTUgQWks5rHs3qgaJpZM4K7I2k .

SamDecrock avatar Dec 14 '16 11:12 SamDecrock

same problem to me. I'm run it on OS X Yosemite

webliupeng avatar Apr 16 '17 14:04 webliupeng

If one client has a public IP,it's not going to work. Both clients need to be behind different NATs, Sam mentions this in his How-To

Just repeating my input on issue #4:

I tested different variations and this is what I got:

clientA<->NATA<->PublicServer<->NATB<->clientB : everything ok clientA<->NATA<->PublicServer<->clientB (no NATB): clientB throws EADDRINUSE. Obviously you get the same reaction when you swap clientA and clientB.

Looking through the code, it would be very easy to extend the client code so it handles fine if client is not behind a NAT, it's actually just ignoring/not running some current code.

I'd close this issue, as far as I can see the SW works as described (unless I missed something ;-)

ccc-tomr avatar Aug 04 '17 23:08 ccc-tomr