Messages not/slowly arriving for NWConnectionGroup/NWMulticastGroup

We're trying to re-implement our proprietary SSDP implementation (currently using CocoaAsyncSocket) using Apple's Network framework for iOS 14, based on Apple's example on how to use multicast networking in an App.

This is the code of our spike:
Code Block swift
guard let multicastGroup = try? NWMulticastGroup(for: [ .hostPort(host: "239.255.255.250", port: 1900) ]) else {
fatalError("Failed to create multicast group")
}
let connectionGroup = NWConnectionGroup(with: multicastGroup, using: .udp)
connectionGroup.setReceiveHandler(maximumMessageSize: 16384, rejectOversizedMessages: true) { message, content, isComplete in
print("Received message from \(String(describing: message.remoteEndpoint))")
if let content = content, let message = String(data: content, encoding: .utf8) {
print("Message: \(message)")
}
}
connectionGroup.stateUpdateHandler = { newState in
print("Group entered state \(String(describing: newState))")
}
connectionGroup.start(queue: .main)
let searchString = "M-SEARCH * HTTP/1.1\r\n" +
"HOST: 239.255.255.250:1900\r\n" +
"MAN: \"ssdp:discover\"\r\n" +
"ST: ssdp:all\r\n" +
"MX: 1\r\n\r\n"
let groupSendContent = Data(searchString.utf8)
Timer.scheduledTimer(withTimeInterval: 5, repeats: true) { _ in
connectionGroup.send(content: groupSendContent) { error in
print("Send complete with error \(String(describing: error))")
}
}


While we see plenty of HTTP/1.1 200 OK responses to our M-SEARCH request in Wireshark, iOS 14 Beta 5 is hardly ever calling NWConnectionGroup's handler (line 6) for any received messages (sent from members of the group to the local endpoint).

Do we need to use different NWParameters settings to make sure this handler is called for every response?

Or is this a bug in iOS 14 Beta 5?

Reported as FB8461681.
Unfortunately this issue is also present in iOS 14 Beta 6.
Still present in iOS 14 Beta 7 (with Xcode 12 Beta 6 - there's no Xcode update, yet?).

Not sure whether this is true for previous beta's, but it currently seems to be like this:
  • all HTTP/1.1 200 OK replies are ignored

  • the NOTIFY * HTTP/1.1 notifications are delivered to NWConnectionGroup's receive handler

Still present in iOS 14 Beta 8 (with Xcode 12 Beta 6 - there's again no Xcode update?):
  • all HTTP/1.1 200 OK replies are ignored

  • NOTIFY * HTTP/1.1 notifications are delivered

Unfortunately this issue is still present in iOS 14 GM (18A373) with Xcode 12 GM (12A7208).
I have an existing (mixed Obj-C/Swift) app that is also experiencing similar issues with receiving multicast messages on iOS 14. Some iOS devices receive them, others don't. We also see different behavior when deploying our app via Xcode vs. TestFlight. No clues on the iOS console.

If you figure anything out or get a response on your radar ticket, please share here. I'll do the same.
Is it mandatory to use NWConnectionGroup to communicate with a group of endpoints on a local network? Or can we continue to use Sockets to send and receive multicast packets?
If NWConnectionGroup is not mandatory does an App still requires com.apple.developer.networking.multicast restricted entitlement?

Is it mandatory to use NWConnectionGroup to communicate with a group
of endpoints on a local network?

I’ll responding on the other thread where you asked the same question.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Still seeing this problem where majority of responses not delivered to the completion handler on iOS 14.0.1. Is this known issue?
@BrettAtBadElf, we are experiencing the same issue in the reception of UDP broadcasted messages on iOS 14, even if we have the com.apple.developer.networking.multicast entitlement. The network authorization dialog never shows up and UDP reception is spurious (sometimes it works, sometimes it don't). I described the issue in detail in another thread (UDP Listener on iOS 14).

I'm in a similar situation to phirk, attempting to move an SSDP implementation to Network.framework.

It's mostly working except for the unicast responses from devices in response to M-SEARCH not being surfaced via the receive handler. All the multicast traffic is appearing as expected.

I've had a snoop on the network traffic with Wireshark and I can see the unicast responses arriving from the other devices on the network but for whatever reason the response never reaches the handler code.

Having been bitten by some of the defaults in Network.framework, I've tried explicitly setting the "disableUnicast" argument in the NWMulticastGroup initialiser to false (also true just in case something's being reversed somewhere) and nothing seems to have an effect.

Is there a way to get the port number associated with the socket NWConnectionGroup is using so I could try setting up an NWListener to work around this issue?
Does the issue have a solved solution?
I want to NWConnectionGroup to achieve SSDP to discovery our company devices, but I can't receive the response HTTP/1.1 200 OK via unicast.
Can someone help me?

And I found a error log would display when I start NWConnectionGroup:
nw_listener_socket_inbox_create_socket IP_DROP_MEMBERSHIP 239.255.255.250:1900 failed [49: Can't assign requested address]
Messages not/slowly arriving for NWConnectionGroup/NWMulticastGroup
 
 
Q