Fail to send udp multicast on port 5683 (CoAP protocol)

I am develop an ios app to communicate with our own inhouse devices.

I am using CoAP udp protocol to discover and communicate with my devices. But I fail to send udp multicast package. If I send udp package to single IP it work.

My profile have request multicast entitlement and I have add it in my app profile.

anyone has clue what is the possible showstopper? Thanks!

A good first step in debugging problems like this is to run your code in the simulator. That’s because the simulator does not implement local network privacy, which rules out a whole raft of potential issues.

So, do your multicast sends work in the sim?

Share and Enjoy

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

Hi, thanks for your reply.

I tried on ios simulator, its the same.

Nope I didnt test it on sim. my intent is only send multicast on LAN.

do you have any other pointer or sample git for me to run the working multicast (on LAN)? Thanks.

I tried on ios simulator, its the same.

Nope I didnt test it on sim.

These two statements seem to contradict each other. I’m going to assume that the first one is correct. Also, I’m going to assume that “its the same” means “it’s the same as on a real iOS device, that is, it fails to send the multicast”.

If those assumptions are correct then this isn’t a local network privacy issue because, as I mentioned earlier, the simulator doesn’t implement local network privacy.

What API are you using for this? NWConnectionGroup? Or BSD Sockets? And what language are you using (Swift, Objective-C, something else)?

Share and Enjoy

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

Hi there! sorry for late reply. I'm using react native lib - react-native-udp. ( https://github.com/tradle/react-native-udp)

im not very sure in the ios implementation which API it is using..

im not very sure in the ios implementation which API it is using

In that case my recommendation is that you escalate this via the support channel for that library.

Share and Enjoy

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

I found out the library is using CocoaAsyncSocket under the hood.

AS for now I will have to write my own ios lib to solve this issue. May I have any pointer where to start? (a swift native ios app)

I will have to write my own ios lib to solve this issue.

There are two APIs for UDP multicast support on iOS:

  • BSD Sockets

  • NWConnectionGroup

I believe that CocoaAsyncSocket uses the former (but this isn’t something I maintain specific expertise in).

Calling BSD Sockets from Swift is definitely not fun. Are you OK with the system requirements of NWConnectionGroup?

Share and Enjoy

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

im happy to have any example code for me to start as ground. im new to ios native app development, will read on these topics. Thanks!

Is your deployment target compatible with NWConnectionGroup? That is, iOS 14 and later?

Share and Enjoy

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

My deployment target now is set to iOS 11 and later.

Not sure what does compatible with NWConnectionGroup mean? Sorry Im still new to iOS app development.

Not sure what does compatible with NWConnectionGroup mean?

NWConnectionGroup is a new Network framework API for multicast. For more on this, see it’s documentation. As shown in the docs, NWConnectionGroup is supported on iOS 14 and later. So, if your deployment target is iOS 14 or later, it would be compatible with NWConnectionGroup.

My deployment target now is set to iOS 11 and later.

And that confirms that it’s not )-:

Have you thought about raising your deployment target? Most iOS devices support version iOS NOW and iOS NOW - 1, which currently means iOS 15 and iOS 14. If you could raise your deployment target to iOS 14 then NWConnectionGroup becomes an option, which would be good because it’s a much nicer API.

If not, your only option for multicast is BSD Sockets and that API has lots of pitfalls, especially when it comes to multicast.

Share and Enjoy

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

NWConnectionGroup is a new Network framework API for multicast. For more on this, see it’s documentation. As shown in the docs, NWConnectionGroup is supported on iOS 14 and later. So, if your deployment target is iOS 14 or later, it would be compatible with NWConnectionGroup.

I see. this is a bumper. We are planning to support at least iOS 12. Which is last iOS version for iPhone 6/ 6plus. The audience on iphone 6 is part of our support audience.

Hi , I am in the same boat. I am using react-native-udp. It works in the simulation for Xcode, but not in the actual iPhone device connected to MacBook.

Also I accidentally find out that it works in iOS14 because the iPhone has not been updated ti iOS16. So it does not work in iOS16.

I also notice that if I run for the first time it asks networking.

Notes below: Xcode Version 14.3 (14E222b) iOS ver 16.4.1 on iPhone 11 info.plist I only have Privacy - Location When In Use Usage Description.

Fail to send udp multicast on port 5683 (CoAP protocol)
 
 
Q