diversario/node-ssdp

startServer() should fail if no ipaddress available

lukewis opened this issue · 2 comments

I'm struggling to understand all of the startup logic, but on the surface this appears to be a bug. Maybe there's a workaround using the "interfaces" array that can be passed as an option? (I couldn't find an example of how to use this option).

Steps to reproduce

  1. Turn OFF wifi and all internet connections
  2. Run the example server script
  3. Notice that no errors/exceptions are thrown
  4. Even if we turn wifi back on at this point (so that we eventually get an ip address), the server won't respond to any M-SEARCH requests

Expected behavior

  • SSDPServer.start() should reject the promise if we can't bind to a "real" ip address (127.0.0.1 shouldn't count)
  • Alternately, the server could implement its own retry logic, but I'm leaning towards just rejecting the promise and leaving this up to the consumer

The module already ignores all internal interfaces (loopback included) but you're correct in that it does not check whether or not it was able to create at least one socket. Rejecting the promise is a good idea.

Published v4.0.0