plasticrake / tplink-smarthome-api

TP-Link Smarthome WiFi API
MIT License
1.02k stars 141 forks source link

Client.startDiscovery() boardcast failed silently @ windows 10 #102

Closed aptxyz closed 2 years ago

aptxyz commented 4 years ago

No devices return from startDiscovery() @ windows 10. After some (crazy) digging, I figure out its because when broadcasting address, 255.255.255.255 will be sent through the first interface in the route table that matches the destination. Then I recall I might have messed up the internet interface somehow from wireshark or hyper-v or whatever it was.

after that, I used my wifi as the broadcasting interface, I am able to retrieve the devices from startDiscovery(), from Scott Lundberg@serverfault, it stated that it should be fixed at the application level. I don't think tplink-smarthome-api did anything wrong, instead the node package dgram should be responsible for that. I'm just reporting that to let you know, it will failed silently due to this.

plasticrake commented 3 years ago

You can specify the interface address you want to use by passing it to startDiscovery({address: '0.0.0.0'})

And you can specify the exact broadcast address to send to as well.

  /**
   * address to bind udp socket
   */
  address?: string;
  /**
   * port to bind udp socket
   */
  port?: number;
  /**
   * broadcast address
   * @defaultValue '255.255.255.255'
   */
  broadcast?: string;