diversario / node-ssdp

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

Conflict with Samsung AllShare #32

Closed jaruba closed 9 years ago

jaruba commented 9 years ago

I'm using node-ssdp to check for MediaRenderer with:

client.search('urn:schemas-upnp-org:device:MediaRenderer:1');

This works great in all cases except when I have Samsung AllShare Agent opened, it seems it creates some conflict as when it is open client.on('response') is never triggered.

I checked the console log, there are no JS errors of any kind. Any thoughts on why this scenario could be an issue for node-ssdp? (I know Samsung AllShare also uses upnp/dlna to share folders and stream to the TV)

ChrisScheffler commented 9 years ago

The agent most likely already reserved port 1900 which is needed for listening for ssdp broadcasts. Therefor the sspd-client socket creation will fail because node-ssdp creates its sockets without flag SO_REUSEADDR. You could change to following code in the lib/index.js:

SSDP.prototype._createSocket = function () { return dgram.createSocket('udp4') } to SSDP.prototype._createSocket = function () { return dgram.createSocket('udp4', reuseAddr: true) } for testing if this solves your issue.

diversario commented 9 years ago

@ChrisScheffler has a valid point. If the proposed change fixes your issue I can release a new version that has exposes an option to set reuseAddr to true.

jaruba commented 9 years ago

@ChrisScheffler @diversario

Seems like a fair solution, I was expecting it to be some sort of port related problem, I just haven't been anywhere near a Samsung TV with DLNA support in this time, I should be able to test it tonight and will report if it fixes it as soon as possible. :)

jaruba commented 9 years ago

I've tested this many times and was unable to reproduce the issue, I believe it may have been caused by the fact that Samsung Allshare also creates a UPNP/DLNA Server of it's own.

If I see this problem appear again I will reopen the ticket but for now, it's working fine when the AllShare Agent is active.