iOS udp broadcast stopped work after upate my device to ios 16

Hi everyone, my app search tv in same networking and this stopped working after updating my ios version to 16.

My app have networking.multicast property in info.plist and I followed the guide to discover other devices on the same network and including i got apple permission to multicast https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_networking_multicast

When i test the app in devices with ios 14 and 15 working perfectly.

someone had this problem?

There are many potential causes for problems like this. Some questions:

  • Have you tested this on the latest iOS 16.x release?

  • What API are you using for broadcasts? Most folks use BSD Sockets but it’s important to be clear.

  • What happens at the API level? Do you get an error?

  • What does your ‘wire’ protocol look like? Are you trying to send broadcasts? Or receive them? Or both?

  • And what happens on the wire? Is it that a broadcast you send is not going out on the wire? Or that you’re not receiving a broadcast?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hello Eskimo, thank you for your prompt response.

Regarding the questions:

  1. Yes, I have tested it on iOS 16.3 and it did not work, It only works on iOS versions below 16.
  2. I am using Flutter in my application, but it is not clear which API is being utilized.
  3. Yes, I am receiving the following errors: "SocketException (SocketException: Send failed (OS Error: No route to host, errno = 65), address = 10.31.2.85, port = 0)"
  4. I am sending and receiving data, my app searches for a TV on the same network, and after connecting, I send data to the TV.
  5. The exception occurred during the initial flow, when searching for a TV.

Here is a part of my code implementation:

final InternetAddress _ipv4Multicast = new InternetAddress("239.255.255.250");
  final InternetAddress _ipv6Multicast = new InternetAddress("FF05::C");
  List<RawDatagramSocket> _sockets = <RawDatagramSocket>[];
  late Timer? _discoverySearchTimer;

  Future createSocket(void Function(String) fn, NetworkInterface bindInterface,
      String bindAddress) async {
    RawDatagramSocket _socket = await RawDatagramSocket.bind(bindAddress, 0);
    _socket.broadcastEnabled = true;
    _socket.multicastHops = 50;
    _socket.readEventsEnabled = true;

    await _socket.listen((event) async {
      print("-- listen(): received event " + event.toString());
      switch (event) {
        case RawSocketEvent.read:
          var packet = _socket.receive();
          _socket.writeEventsEnabled = true;
          _socket.writeEventsEnabled = true;

          if (packet == null) {
            return;
          }

          var data = utf8.decode(packet.data);
          print("-- listen(): data received");
          fn(data);
          break;
      }
    });

    try {
      _socket.joinMulticast(_ipv4Multicast, bindInterface);
    } on OSError {}

    try {
      _socket.joinMulticast(_ipv6Multicast, bindInterface);
    } on OSError {}
    _sockets.add(_socket);
  }

  void stop() {
    if (_discoverySearchTimer != null) {
      _discoverySearchTimer!.cancel();
      _discoverySearchTimer = null;
    }
  }

  void request([String? searchTarget]) {
    if (searchTarget == null) {
      searchTarget = "ssdp:all";
    }
    var buff = new StringBuffer();
    buff.write("M-SEARCH * HTTP/1.1\r\n");
    buff.write("HOST:239.255.255.250:1900\r\n");
    buff.write('MAN:"ssdp:discover"\r\n');
    buff.write("MX:1\r\n");
    buff.write("ST:$searchTarget\r\n\r\n");
    var data = utf8.encode(buff.toString());

    for (var socket in _sockets) {
      try {
        var res = socket.send(data, _ipv4Multicast, 1900);
        print("-- request(): sended bytes $res");
      } on SocketException {}
    }
  }

I am using Flutter in my application, but it is not clear which API is being utilized.

Just to set expectations, I can only help you with Apple APIs. If you need help translating that into your third-party environment, I recommend that you raise that via its support channel.

I am receiving the following errors

From which specific call?

I am sending and receiving data

You are clearly sending multicasts. Are the responses multicast? Or unicast?

The exception occurred during the initial flow, when searching for a TV.

That’s not where I was going with this. Rather, I was suggesting that you use an RVI packet trace to see if what happening from the network’s perspective. See Recording a Packet Trace.


In your original post you wrote:

My app have networking.multicast property in Info.plist

Is that a Flutter thing? Because it doesn’t correspond to anything on the Apple side. Moreover, it ties in with this:

including i got apple permission to multicast

That “permission” comes in terms of an entitlement. I’ve seen folks mistakenly try to include entitlements in their Info.plist, which isn’t effective. Are you sure that your app is signed with the multicast entitlement?

To test this:

  1. Build your app for the device.

  2. Choose Product > Show Build Folder in Finder.

  3. Navigate to Products > Debug-iphoneos.

  4. Find your app and run this Terminal command against it:

% codesign -d --entitlements - /path/to/your.app

Does it show the com.apple.developer.networking.multicast entitlement?


Oh, and btw, read this: Local Network Privacy FAQ.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

hello, I also met the same problem as you. May I ask how you solved the problem later?

iOS udp broadcast stopped work after upate my device to ios 16
 
 
Q