Yortw / RSSDP

Really Simple Service Discovery Protocol - a 100% .Net implementation of the SSDP protocol for publishing custom/basic devices, and discovering all device types on a network.
http://yortw.github.io/RSSDP/
MIT License
282 stars 66 forks source link

iOS and SearchAsync #118

Closed Steve0212a closed 10 months ago

Steve0212a commented 11 months ago

I am using RSSDP for a .Net Maui project (I have used it in the past for Windows too). It is working perfectly in Android, but it is not working in IOS (iPhone 13 Pro, v16.5.1 (c)).

Here is the code I am executing:

      // This code goes in a method somewhere.
      using var deviceLocator = new SsdpDeviceLocator();

      // scan for dongles
      var foundDevices = await deviceLocator.SearchAsync("<my Target String>", TimeSpan.FromSeconds(3));

iOS prompts me for the network access permission which I accept. I know the permission access s is working because other calls in the app are working (REST API calls to a host on the local subnet). However, I get this exception immediately.

System.Net.Sockets.SocketException (65): No route to host
   at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, Boolean disconnectOnFailure, String callerName)
   at System.Net.Sockets.Socket.SendTo(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, EndPoint remoteEP)
   at System.Net.Sockets.Socket.SendTo(Byte[] buffer, EndPoint remoteEP)
   at Rssdp.UdpSocket.SendTo(Byte[] messageData, UdpEndPoint endPoint)
   at Rssdp.Infrastructure.SsdpCommunicationsServer.SendMessageIfSocketNotDisposed(Byte[] messageData, UdpEndPoint destination)
   at Rssdp.Infrastructure.SsdpCommunicationsServer.<>c__DisplayClass29_0.<SendMessage>b__0()
   at Rssdp.Infrastructure.SsdpCommunicationsServer.Repeat(Int32 repetitions, TimeSpan delay, Action work)
   at Rssdp.Infrastructure.SsdpCommunicationsServer.SendMessage(Byte[] messageData, UdpEndPoint destination)
   at Rssdp.Infrastructure.SsdpDeviceLocatorBase.BroadcastDiscoverMessage(String serviceType, TimeSpan mxValue)
   at Rssdp.Infrastructure.SsdpDeviceLocatorBase.SearchAsync(String searchTarget, TimeSpan searchWaitTime)

Any help would be appreciated.

Thanks

Steve0212a commented 10 months ago

OK - I found the issue - hope this helps with others with IOS issues. You have to request a special entitlement from Apple for multicast. This took about a week for us. Hope it helps

https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_networking_multicast https://developer.apple.com/forums/thread/663271