Closed trzy closed 2 years ago
Some additional information: I think we can rule out network issues. I ran a WireShark capture and found that packets do arrive from the other device (IP 100 is my PC and 107 is the Android device I am running the same code on):
1 0.000000 192.168.0.100 239.255.255.250 SSDP 217 M-SEARCH HTTP/1.1 2 10.153707 192.168.0.100 239.255.255.250 SSDP 136 M-SEARCH HTTP/1.1 3 10.256424 192.168.0.100 239.255.255.250 SSDP 136 M-SEARCH HTTP/1.1 4 10.356536 192.168.0.100 239.255.255.250 SSDP 136 M-SEARCH HTTP/1.1 5 23.256799 192.168.0.100 239.255.255.250 SSDP 413 NOTIFY HTTP/1.1 6 23.356948 192.168.0.100 239.255.255.250 SSDP 413 NOTIFY HTTP/1.1 7 23.457076 192.168.0.100 239.255.255.250 SSDP 413 NOTIFY HTTP/1.1 8 23.557221 192.168.0.100 239.255.255.250 SSDP 411 NOTIFY HTTP/1.1 9 23.657563 192.168.0.100 239.255.255.250 SSDP 411 NOTIFY HTTP/1.1 10 23.757906 192.168.0.100 239.255.255.250 SSDP 411 NOTIFY HTTP/1.1 11 23.858051 192.168.0.100 239.255.255.250 SSDP 422 NOTIFY HTTP/1.1 12 23.958170 192.168.0.100 239.255.255.250 SSDP 422 NOTIFY HTTP/1.1 13 24.058339 192.168.0.100 239.255.255.250 SSDP 422 NOTIFY HTTP/1.1 14 24.158553 192.168.0.100 239.255.255.250 SSDP 463 NOTIFY HTTP/1.1 15 24.258679 192.168.0.100 239.255.255.250 SSDP 463 NOTIFY HTTP/1.1 16 24.358833 192.168.0.100 239.255.255.250 SSDP 463 NOTIFY HTTP/1.1 17 27.987695 192.168.0.188 239.255.255.250 SSDP 217 M-SEARCH HTTP/1.1 18 28.993433 192.168.0.188 239.255.255.250 SSDP 217 M-SEARCH HTTP/1.1 19 29.994276 192.168.0.188 239.255.255.250 SSDP 217 M-SEARCH HTTP/1.1 20 30.995189 192.168.0.188 239.255.255.250 SSDP 217 M-SEARCH HTTP/1.1 21 71.685383 192.168.0.188 239.255.255.250 SSDP 211 M-SEARCH HTTP/1.1 22 72.696623 192.168.0.188 239.255.255.250 SSDP 211 M-SEARCH HTTP/1.1 23 73.696874 192.168.0.188 239.255.255.250 SSDP 211 M-SEARCH HTTP/1.1 24 74.697067 192.168.0.188 239.255.255.250 SSDP 211 M-SEARCH HTTP/1.1 25 83.482031 192.168.0.107 239.255.255.250 SSDP 136 M-SEARCH HTTP/1.1 26 83.963206 192.168.0.107 239.255.255.250 SSDP 136 M-SEARCH HTTP/1.1 27 84.062279 192.168.0.107 239.255.255.250 SSDP 136 M-SEARCH HTTP/1.1 28 89.251050 192.168.0.107 239.255.255.250 SSDP 396 NOTIFY HTTP/1.1 29 89.345021 192.168.0.107 239.255.255.250 SSDP 396 NOTIFY HTTP/1.1 30 89.447675 192.168.0.107 239.255.255.250 SSDP 396 NOTIFY HTTP/1.1 31 89.549279 192.168.0.107 239.255.255.250 SSDP 394 NOTIFY HTTP/1.1 32 89.653658 192.168.0.107 239.255.255.250 SSDP 394 NOTIFY HTTP/1.1 33 89.759647 192.168.0.107 239.255.255.250 SSDP 394 NOTIFY HTTP/1.1 34 89.843073 192.168.0.107 239.255.255.250 SSDP 405 NOTIFY HTTP/1.1 35 89.950249 192.168.0.107 239.255.255.250 SSDP 405 NOTIFY HTTP/1.1 36 90.050953 192.168.0.107 239.255.255.250 SSDP 405 NOTIFY HTTP/1.1 37 90.150848 192.168.0.107 239.255.255.250 SSDP 446 NOTIFY HTTP/1.1 38 90.251845 192.168.0.107 239.255.255.250 SSDP 446 NOTIFY HTTP/1.1 39 90.353418 192.168.0.107 239.255.255.250 SSDP 446 NOTIFY * HTTP/1.1
For some reason, however, I am not getting notification events.
Digging into the code further, I see now that what Rssdp is getting are NOTIFY messages. That's how the client sees is alerted to itself. But these NOTIFY messages aren't received from the other (remote) client in SsdpCommunicationServer::ProcessMessage(). Yet, Wireshark sees them. Hmm...
Ah... the issue seems to be Unity :( I suspect something about async execution is not working as intended in Unity. Everything works fine in a console app. Long shot... but maybe you've dealt with Unity before and might know where the problem could be? It's clearly still receiving some messages on the socket it is listening on.
It was Windows Firewall (which seems to somehow keep resetting its rules for the application in question).
Hi,
I'm having a couple of issues:
Using the callback-based example in the documentation to search for broadcasts that I publish (using your publisher example directly), I only receive three callback events. I notice in the code that you re-send each UDP message thrice, so this makes sense. But I never get any more after that unless I keep calling SearchAsync() repeatedly. I thought that StartListeningForNotifications() should eliminate the need for that?
I only receive the broadcasts generated by the same device. That is, if I start the app on a different computer on the same network, I do not see those broadcasts (and that instance, in turn, only sees its own broadcasts). UPnP is enabled on my wireless router. I will sit down with WireShark tomorrow to see if I can detect the packets at all, I haven't tried that yet. But I wonder whether I'm just using the code incorrectly.
Pardon the incredibly messy code (I am just trying to learn how this works before developing a proper implementation) but here is my listener (this is in a Unity app):
And here is the publisher:
Any tips would be appreciated.
Thanks!