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

Unstable return of IPv4 address #132

Open
maziarzamani opened this issue Apr 21, 2015 · 1 comment
Open

Unstable return of IPv4 address #132

maziarzamani opened this issue Apr 21, 2015 · 1 comment

Comments

@maziarzamani
Copy link

I am experiencing problems with returning the IPv4 address on OSX.

Rarely i see a IPv4 address but rest of the time its IPv6.

When i check with the application Bonjour Browser on OSX i see the IPv4 address without any problems, so i assume its an issue with the module.

Heres the code:

var mdns    = require('mdns')
  , listOfOscDevices = { /*name: {adresses: ['192.168.0.24', 'fe80::0:18'], port: 10001}}*/ }
  ;
var mdnsBrowser = mdns.createBrowser(mdns.udp('put'));

mdnsBrowser.on('serviceUp', function(service) {
  // ignore duplicate ups
  if(listOfOscDevices[service.name]) return;

  listOfOscDevices[service.name] = {'addresses': service.addresses, 'port': service.port};
  var cnt = Object.keys(listOfOscDevices).length;

  console.log('osc device "'+service.name+' up at '+service.addresses+':'+service.port+', now '+cnt+' devices on the net');
});

mdnsBrowser.on('serviceDown', function(service) {
// ignore duplicate downs
  if(!listOfOscDevices[service.name]) return;

  var device = listOfOscDevices[service.name];

  delete listOfOscDevices[service.name];
  var cnt = Object.keys(listOfOscDevices).length;

  console.log('osc device "'+service.name+' up at '+device.addresses+':'+device.port+', now '+cnt+' devices on the net');
});

console.log('listening for osc-compatible devices on the net')
mdnsBrowser.start();
@agnat
Copy link
Owner

agnat commented Oct 15, 2016

Apologies for not responding...

Nope, the module is fine. It is how the underlying system service behaves. IIRC, the default is to return the first address available, which is (almost) always IPv6. You can fine-tune the behavior using the resolver chain, but there will be dragons...

The best cause of action is to fix the applications to support IPv6, though.

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

No branches or pull requests

2 participants