Open gabrielmagno opened 8 years ago
+1
hi @gabrielmagno any chance you could submit a pull request or just drop some details into a reply here? I'd like to get this fixed as well and if I can do it without re-inventing the wheel that would be nice!
Hi @ghenry22 . I've just submitted a pull request that seems to fix this issue. I've tested it back them when I reported the issue, and it solve the problem for me.
DLNA renderers in a multi-router environment are not found
Steps to Reproduce
I have an LG TV (with builtin DLNA) and a Raspberry Pi running Raspbmc (with UPnP controller/renderer enabled). Both are connected in a wireless bridge router, which is connected into my main router. My android device, from where I run Connect-SDK, is connected into the main router. With this setup, Connect-SDK does not list them as renderers. If I connect them directly into the main router, Connect-SDK will show them.
I looked into the code, and it seems that the library does not set the proper value of TTL when searching for devices. According to the UPnP Specification:
By inspecting the packet of SSDP M-SEARCH with Wireshark, it is indeed set as TTL=1, while it should be set as TTL=4.
In Java, it's possible to do that by calling setTimeToLive in the socket object. This method is available only to Multicast sockets.
I looked into Connect-SDK's code, and noticed that a Datagram socket is used to send the SSDP search. It should actually be of the Multicast type, so that we could call
socket.setTimeToLive(4)
before binding it.I tried to fix it myself, and now both my TV and Kodi are listed as renderers. I could issue a pull request with my simple fix, but was not sure if the way I did was the best way, so I decided to report my findings with all the details, so that you could handle it properly.