jimmywarting / wemo-client

JavaScript client library for controlling and subscribing to Wemo Devices
MIT License
132 stars 40 forks source link

Issues with multiple network interfaces #49

Closed joe248 closed 7 years ago

joe248 commented 7 years ago

I'm utilizing wemo-client via homebridge / homebridge-platform-wemo. I'm running it on a CHIP. When I don't have my USB hub connected, everything works correctly and all of my Wemo devices are discovered. If I plug in my USB hub it adds additional network interfaces, one of which node-ssdp ends up binding to instead of the correct interface. This results in node-ssdp not being able to find any devices.

The latest node-ssdp (3.2.1) supports multiple network interfaces. By installing that and passing the option explicitSocketBind: true into the node-ssdp constructor, I was able to get things working again when my USB hub is connected.

Would it be possible to update this library to use the latest node-ssdp?

I'm not sure what the best course of action is regarding the explicitSocketBind parameter; whether that should be added to wemo-client or further up in homebridge-platform-wemo.

timonreinhard commented 7 years ago

Thanks for your feedback. I just updated the all the dependencies (long overdue anyway) and will make a new release the next days. Regarding explicitSocketBind: I'd rather leave it to the dependents to set this option.

joe248 commented 7 years ago

Thanks!

devbobo commented 7 years ago

@timonreinhard please let us know once you have released a new version...thanks

joe248 commented 7 years ago

Actually, another change is required to support multiple network interfaces. The function that generates the subscription callback URL is also grabbing my USB hub's address instead of the wlan0 adapter.

One solution might be to only consider interfaces with a netmask of 255.255.255.0 (my USB hub's netmask is 255.255.0.0). Another would be to just add a config option to specify what interface to listen on for subscriptions (en0, wlan0, etc). If we went that route we'd need to pass that option through to homebridge-platform-wemo as well.

timonreinhard commented 7 years ago

Allowing to specify the bound interface sounds best to me. Mind creating a PR for that?

joe248 commented 7 years ago

Sure. If it can't find the specified interface should it throw an error or just fall back to the current implementation?

timonreinhard commented 7 years ago

As I understood your proposal, it will introduce a new optional setting that allows to specify the network interface to use. Not providing that option would default to the current behavior so that the change is non-breaking. If that's what you had in mind, throwing an error when the desired network interface can not be found looks good to me.