jimmywarting / wemo-client

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

Discovery issue after network settings changes? #47

Closed ryexley closed 7 years ago

ryexley commented 7 years ago

I have an app that I've written that uses this client. I use the discovery function to discover devices available on the network. That function was working fine until recently when I made some changes to my local wifi network, and now discovery seems to fail unless I reset the device on my network.

I was having some problems with wifi range with my airport extreme router. So I decided to just use my ISPs modem/router for my wireless network, and I reconfigured my airport extreme to just be an extender of the other devices wireless network. In the process of making these changes, I setup the network name and password to be identical to what my airport extreme was previously broadcasting, but now it's made available by my ISPs device, and simply extended by my airport extreme.

Since having done that, discovery always fails to find my device, until/unless I do a full reset of my device on the network. Even then, when I can get my app to discover it, it will only discover it until the computer running the app has been rebooted. After a reboot, it fails to find it anymore.

I'm not real familiar with how the discovery function is working under-the-hood, but...do you have any idea what might be going on here? Why am I no longer able to discover my device?

timonreinhard commented 7 years ago

My first guess would be that the SSDP multicast doesn't pass the Airport Extreme. A quick workaround would be to give your Wemo devices static IPs (via the DHCP settings of your router) and then use the Wemo#load method instead of trying to discover the devices.

Do the devices still appear when using the Wemo mobile app?

ryexley commented 7 years ago

So, you might be onto something there. My ISPs router, I have it setup to broadcast the 2.4ghz and 5ghz networks with separate SSIDs, and the airport extreme only extends the 5ghz network. Of course, the wemo is configured on the 2.4ghz network, as that's all they work on. I did notice that I'm able to discover it if I briefly switch over to the 2.4ghz network...so, it must have something to do with that.

The strange thing to me is, yes, the device still appears in the wemo mobile app, and everything works exactly the same there, nothing changed at all. So internally, it seems able to interact with it just fine...maybe it's connecting directly to it or something? I dunno.

I am considering revamping my app to cache the address of each device upon discovery and persist it to disk, and then just run wemo.load after the initial discovery.

timonreinhard commented 7 years ago

Sadly Wemo devices don't support mDNS discovery which is supposed to work more reliable under different network setups, so I don't see any way to improve that.

ryexley commented 7 years ago

Thanks for replying. I wasn't really expecting anything to change, was mostly just wondering if there was something I was missing. This seems to definitely have to do with the way I set my network up, and it makes perfect sense now. I understand why it was giving me issues. Thanks again.