diversario / node-ssdp

node.js SSDP client/server.
MIT License
274 stars 118 forks source link

is there any code error? #86

Closed huoxingang closed 6 years ago

huoxingang commented 6 years ago

i use node-ssdp in my project, once it throw errs : ReferenceError: addMembership is not defined at Socket.onSocketListening (...\node_modules._node-ssdp@3.2.1@node-ssdp\lib\index.js:245:22) at emitNone (events.js:91:20) at Socket.emit (events.js:185:7) at startListening (dgram.js:121:10) at _handle.lookup (dgram.js:226:7) at _combinedTickCallback (internal/process/next_tick.js:83:11) at process._tickCallback (internal/process/next_tick.js:104:9)

so check the source code in lib/index.js: if (e.code === 'ENODEV' || e.code === 'EADDRNOTAVAIL') { self._logger('Interface %s is not present to add multicast group membership. Scheduling a retry. Error: %s', addr, e.message) setTimeout(addMembership, 5000) } else { throw e }

addMembership is undefined. q 1 : perhaps it should be socket.addMembership ? q 2 : when will code run here? sometime my project would quit and i can't got logger, so i want confirm if this is the bug point.

diversario commented 6 years ago

Yes, that's most definitely a bug. As you pointed you, it should be socket.addMembership. This bit of code would run basically when we were unable to find the interface we're trying to use. Not entirely sure why it happens in your case.

diversario commented 6 years ago

Try v3.2.5 I just published, @huoxingang