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

Error: bind EADDRINUSE #31

Closed
drasko opened this issue Feb 8, 2015 · 10 comments
Closed

Error: bind EADDRINUSE #31

drasko opened this issue Feb 8, 2015 · 10 comments
Labels
Milestone

Comments

@drasko
Copy link

drasko commented Feb 8, 2015

Trying the example on my Debian built Node v0.12.0:

drasko@Lenin:~/nw/test$ DEBUG=mdns:* node test.js 
  mdns:lib:networking interface +0ms wlan0 192.168.0.46
  mdns:lib:networking creating socket for +4ms wlan0
  mdns:lib:networking creating socket for +3ms pseudo multicast
  mdns:lib:networking bindToAddress +4ms wlan0
events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: bind EADDRINUSE
    at exports._errnoException (util.js:746:11)
    at dgram.js:224:28
    at dns.js:85:18
    at process._tickCallback (node.js:355:11)
    at Function.Module.runMain (module.js:503:11)
    at startup (node.js:129:16)
    at node.js:814:3
drasko@Lenin:~/nw/test$ 
@kmpm kmpm added the bug label Feb 9, 2015
@kmpm kmpm added this to the Node v0.12 milestone Feb 9, 2015
@kmpm
Copy link
Collaborator

kmpm commented Feb 9, 2015

Do you get this if you first stop the avahi daemon?

node v0.10 with avahi running, tests and examples/service.js works
node v0.12 with avahi running, tests and examples/service.js fails with EADDRINUSE
node v0.12 without avahi running, tests and examples/service.js works

More investigation needed

@kmpm
Copy link
Collaborator

kmpm commented Feb 9, 2015

Ok.. as I suspected.
If I don't open the pseudo multicast "0.0.0.0:5353" it will work even with avahi running but we shouldn't do that. I don't know why v0.10 didn't fail. It should have.
Two competing mdns services is NOT a good thing. So using this to advertise services at the same time as avahi or bonjour is running will fail in one level or another.
This is probably a invalid issue but I would appreciate feedback on if it works without avahi running.

kmpm added a commit that referenced this issue Feb 9, 2015
@kmpm
Copy link
Collaborator

kmpm commented Feb 9, 2015

If you want to use the discovery part on a system with avahi or bonjour I have added a way of excluding the offending interface.

mdns.excludeInterface('0.0.0.0');

before ANY other activity.

@drasko
Copy link
Author

drasko commented Feb 9, 2015

I did not really try examples/service.js, but examples/simple.js. I don't need to export service, I need just to browse existing services around me.

And yes, it does not work even with avahi stopped.

How to install version with your fix? I tried:

npm install https://github.com/kmpm/node-mdns-js.git

but this does not work...

I don't understand - why do I have to stop avahi just to browse the existing services? Can examples/simple.js work without stopping avahi?

@drasko
Copy link
Author

drasko commented Feb 9, 2015

Ah, replacing

npm install https://github.com/kmpm/node-mdns-js.git

by

npm install git://github.com/kmpm/node-mdns-js.git

works.

And now test program works even with avahi running.

@drasko
Copy link
Author

drasko commented Feb 9, 2015

How to retrieve fullname and host?

I need to recognize the service by the name, like "myService.local". For now I am getting in name just 'http', 'smb', or 'ssh' for example:

data: { addresses: [ '192.168.0.26' ],
  query: [ '_services._dns-sd._udp.local' ],
  type: 
   [ { name: 'ssh',
       protocol: 'tcp',
       subtypes: [],
       description: 'SSH Remote Terminal' },
     { name: 'smb',
       protocol: 'tcp',
       subtypes: [],
       description: 'Microsoft Windows Network' },
     { name: 'http',
       protocol: 'tcp',
       subtypes: [],
       description: 'Web Site' } ],
  interfaceIndex: 0,
  networkInterface: 'wlan0' }

@jnath
Copy link

jnath commented Feb 18, 2015

I found maybe something.
On node, it's work perfectly, but on io.js my app crash with "Error: bind EADDRINUSE 0.0.0.0:5353".

the last build alpha1/2/3 of nw.js build with io.js. and mdns-js seems not compatible with io.js.

@jnath
Copy link

jnath commented Feb 19, 2015

maybe help

nodejs/node#554

use reuseAddr: true
var s = dgram.createSocket({ type: 'udp4', reuseAddr: true })

@xat
Copy link

xat commented Feb 19, 2015

yes, reuseAddr: true seems to fix the issue.

@auchenberg
Copy link

Can you push a new version to NPM? Thanks!

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

No branches or pull requests

5 participants