huin / goupnp

UPnP client library for Go (#golang)
BSD 2-Clause "Simplified" License
417 stars 84 forks source link

Unable to find devices most of the time #23

Closed smares closed 6 years ago

smares commented 6 years ago

I just started using this library and initially was very happy that clients, errors, err := av1.NewAVTransport1Clients() found my Samsung TV and Teufel loudspeakers, but soon after that, it stopped working and clients was empty. After like 20 runs, it worked again, but eventually it's no longer finding anything. My system is Windows 10. Before using your library, I played around with Developer Tools for UPnP Technologies (http://www.meshcommander.com/upnptools) and their "Device Spy" that works all the time, so it doesn't appear to be a limitation of my OS or network / firewall. Any idea what might be wrong? Should I use Wireshark to inspect the traffic or do you recommend something else?

huin commented 6 years ago

The Wireshark captures would be particularly useful. Specifically comparing the working tool does versus what goupnp does.

smares commented 6 years ago

Great, now I cannot reproduce the issue after a PC reboot. 😅

By the way, device.go has RequestSCDP(). Shouldn't this be RequestSCPD()?

huin commented 6 years ago

Dang, that's a pain. I was vaguely wondering if it's a lack of IPv6 support in the library.

And yes, looks like that's a typo. I guess I should alias that (but retain old for compatibility). Thanks for spotting it :)

smares commented 6 years ago

Hmm, not sure if it's an IPv6 problem. Wouldn't that mean that it should never find the devices?

Do you have experience with Wireshark? What should I be looking for? Even though I turned off all services and programs that connect to the Internet, as soon as I start recording, I get lots of entries. I thought UPnP is mostly UDP at least when it comes to discovery, but that SDK I mentioned seems to be doing several TCP requests to my intranet as well.

huin commented 6 years ago

The IPv6 theory is based on a couple of things: one is that this library hasn't been updated to support IPv6, and the other is pondering if the appearance and disappearance of the problem you experienced was maybe an IPv4 DHCP lease expiring and not being renewed (where IPv6's own auto configuration would probably survive). But the latter being a cause is a complete guess.

I've used Wireshark, although a bit rusty. What might work best is to apply a filter for UDP packets that have port 1900 as either source or destination. That should cut out most of the noise.

smares commented 6 years ago

Closing as I really cannot reproduce. In case I can, I'll be back with Wireshark dumps. :)

huin commented 6 years ago

Thanks, and please do :)