swissmanu / harmonyhubjs-discover

A Node.JS library which lookups available Logitech Harmony hubs in the local network.
MIT License
23 stars 9 forks source link

Port not configurable #4

Open maddox opened 8 years ago

maddox commented 8 years ago

It looks like this uses port 5224 when doing the UPnP. Because of this, only a single instance of harmonyhubjs-discover can be used on a single computer at a time.

I have a project that uses this, harmony-api. Some people use this at the same time as the Homebridge plugin that also uses harmonyhubjs-discover. When starting one after the other, it breaks, because the port is in use. You can see an issue regarding this here.

If the port was configurable, implementers could pass in a port when starting harmonyhubjs-discover and multiple instances could be used.

swissmanu commented 8 years ago

Port 5224 is used to emit the UDP broadcast into the network (https://github.com/swissmanu/harmonyhubjs-discover/blob/master/lib/ping.js#L8). Any Harmony Hub is listening on this port and replies to the port configured via the Explorers parameter (https://github.com/swissmanu/harmonyhubjs-discover/blob/master/lib/explorer.js#L57)

On https://github.com/swissmanu/harmonyhubjs-discover/blob/master/lib/ping.js#L15, I implemented a bind on the socket once. I am not sure why binding the socket is necessary at all... I try to look into and get rid of this, because this would totally solve the problem.

harmony-api looks cool btw! Glad harmonhubjs-client finds its way into another project. Would you like to be listed in the ecosystems section of harmonhub-clients readme?

maddox commented 8 years ago

Thanks for the fast reply. All that makes sense. It'd be great to get it a little more flexible.

harmony-api looks cool btw!

Thanks! All from standing on your shoulders though, heh. Sure, I'd love it to be listed there, thanks.

f00j00 commented 6 years ago

So is this possible to change the port ad i'm using 1 for homebridge instance and another for harmony-api?