Open skhavari opened 10 years ago
Hi Sam,
Thanks for the report. I'll take a look at this. I remember writing that code and thinking that I would have to revisit it later!
--Ian
On 06/24/2014 03:03 PM, Sam Khavari wrote:
|ssdpUnicastDiscoverImpl| & |ssdpMulticastDiscoverImpl| depend on IPV4 address but don't ensure IPV4 addresses are used.
The code currently grabs the first entry returned by |net.Interface.Addrs()| and on my machine the following is returned:
Addr[0] = fe80::72cd:60ff:fef3:75ad/64 Addr[1] = 192.168.1.68/24 Since the first entry is an IPV6 entry the code issues a panic and fails to complete discovery.
— Reply to this email directly or view it on GitHub https://github.com/ianr0bkny/go-sonos/issues/2.
I managed to get by this by disabling IPV6 on mac using the instructions here http://help.unc.edu/help/how-do-i-disable-ipv6-on-mac-os-x/.
Disabling IPV6 and re-enabling it pushes the IPV6 entry to the bottom of the Addrs() array.
I've checked in a patch that should accept IPv4 or IPv6 [my code was accepting IPv4 only]. If you get a chance, please let me know if it works for you. Thanks.
i'll give it a shot later this afternoon and let you know how it goes.
that didn't seem to do it
panic: listen udp [fe80::72cd:60ff:fef3:75ad]:13104: bind: can't assign requested address
goroutine 1 [running]:
runtime.panic(0x3176a0, 0xc210046680)
/usr/local/go/src/pkg/runtime/panic.c:266 +0xb6
github.com/ianr0bkny/go-sonos/ssdp.(*ssdpDefaultManager).ssdpDiscoverImpl(0xc210039a20, 0x363bf0, 0x3, 0x35aa90, 0x5, ...)
$GOPATH/src/github.com/ianr0bkny/go-sonos/ssdp/ssdp.go:903 +0xd5
github.com/ianr0bkny/go-sonos/ssdp.(*ssdpDefaultManager).Discover(0xc210039a20, 0x363bf0, 0x3, 0x35aa90, 0x5, ...)
$GOPATH/src/github.com/ianr0bkny/go-sonos/ssdp/ssdp.go:329 +0x70
github.com/ianr0bkny/go-sonos.Discover(0x363bf0, 0x3, 0x35aa90, 0x5, 0x868708, ...)
$GOPATH/src/github.com/ianr0bkny/go-sonos/sonos.go:247 +0x9e
main.discoverSonos()
$PROJ_PATH/sonos.go:22 +0xb7
main.main()
$PROJ_PATH/sonos.go:103 +0x30
exit status 2
The IPV6 address on this mac test machine is a link-local address and needs to be qualified with a source address or zone. on mac/linux this needs to be qualified with the interface name it belongs to...
eg:
net.JoinHostPort(ipaddr.IP.String()+"%en0", TEST_DISCOVER_PORT)
with that change, the call to ListenUDP succeeds. Fun.
on mac this does the trick
qualified_ipaddr := ipaddr.IP.String()
if ipaddr.IP.IsLinkLocalMulticast() == true || ipaddr.IP.IsLinkLocalUnicast() {
qualified_ipaddr = ipaddr.IP.String() + ifi.Name
}
addr_port := net.JoinHostPort(qualified_ipaddr, TEST_DISCOVER_PORT)
finding more IPV6 related issues. Modified my local build to pick up the first IPV4 address and things are working great.
Thanks for digging into this. I'm going to have to set-up an IPv6 address on a VMware machine and see if I can't shake out some of these bugs!
On 06/26/2014 09:21 PM, Sam Khavari wrote:
finding more IPV6 related issues. Modified my local build to pick up the first IPV4 address and things are working great.
— Reply to this email directly or view it on GitHub https://github.com/ianr0bkny/go-sonos/issues/2#issuecomment-47299035.
As a VMware employee and share holder, many thanks.
Any progress in this issue? I have the same problem on my macbook.
Is there any reason not to support a global listener? I'd be fine with this for my use case.
+1 - I could use a fix here.
ssdpUnicastDiscoverImpl
&ssdpMulticastDiscoverImpl
depend on IPV4 address but don't ensure IPV4 addresses are used.The code currently grabs the first entry returned by
net.Interface.Addrs()
and on my machine the following is returned:Since the first entry is an IPV6 entry the code issues a panic and fails to complete discovery.