-
Notifications
You must be signed in to change notification settings - Fork 520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multicast UDP Packets Stopped Working on iOS MAUI App #21814
Comments
Thank you for moving this to the right place. Often it is hard to know exactly where to put things. |
I just realized that I titled this wrong and gave some wrong information. I am trying to send a BROADCAST packet and not multicast. You can see that in the udpClient.Send because the IP address is 255.255.255.255. |
So I tried creating a very simple test app in .NET 7, and it still fails for me (it prints "Exception: No route to host") This is what it does: try {
using var udpClient = new UdpClient (new IPEndPoint(IPAddress.Any, 12345));
var sendbuf = new byte [16];
udpClient.Send (sendbuf, "255.255.255.255", 12345);
Console.WriteLine ($"UDP message sent");
} catch (Exception e) {
Console.WriteLine($"Exception: {e.Message}");
} Would you be able to provide a working .NET 7 project we can use to diagnose this?
One potential reason could be if you updated your iOS device to a new iOS version. |
Actually I think this is the case, I tried on an iPhone with iOS 15.7, and the UDP call worked. |
So what does this mean moving forward? Is this a new restriction on iOS that makes it so I can't do what I need to do or is this something your team can fix? |
I'm not sure: if you can create a working Xcode sample, we can look into if we're doing something wrong and fix it. If you can't create a working Xcode sample, then there's no way for this to work in a .NET project either. |
I found this article that says my app must be signed with the multicast entitlement even for broadcast operations. It also talks about making sure that I don't assume the interface name is 'en0'. I know the C# APIs don't allow me to specify en0 as far as I can tell, so does the code you guys use en0 anywhere or make any assumptions about the interface name? https://developer.apple.com/documentation/technotes/tn3179-understanding-local-network-privacy |
No, we don't make any such assumptions. |
Ok. I have posted in the apple developer forums to try to get some help in creating a Swift application. Here is my post: |
I believe this issue is still on going. Even though I have posted in the Apple forums I have not received any responses there. I still expect the dotnet team to help fix this. Maybe you guys can do some research and reach out to contacts at Apple that I don't have access to? |
Stackoverflow might be another place to ask.
The fact that a restricted entitlement seems to be required to make this work makes it more complicated, because it unfortunately means we can't create a working sample project.
We don't have any contacts for issues like this, the recommended way is to do as you did (post in the Apple forums), alternatively raise a code-level support request with Apple (https://developer.apple.com/support/technical/). |
I have been working with Apple on this. There is a really great developer there who will be able to help. What I need at this point is a good Xcode example that I can share with them. I did some research and came up with my own example using the NWConnection class in Swift. The developer at Apple says that NWConnection is not made to do broadcast reliably. So my question back to you is whether you can share the method that dotnet is using to do the broadcast base on the C# code that I am using in my original post? If I can have access to the native code you are using to implement that in iOS, then maybe I can create an Xcode example to share with Apple and then we can get to the bottom of this. |
@rolfbjarne Please join this Apple thread. I have been getting great responses from the Apple developer over networking. He has written some articles. He also asked that I ask you to participate in this thread because he loves to collaborate with other tools vendors. I am hoping you can look into his suggestions and code and find what you are doing differently that would cause the issue I am seeing. |
@tpitman I'm having the same issue. .NET8 iOS application that use UDP that was working for years, and out of sudden it breaks with iOS 18.1 This thread has been marked as Closed, so I guess they won't check it again. |
I am hoping Rolf will open it back up with new information based on what I have found talking to Apple. |
@tpitman The more I'm digging into it, the more it seems to be a .NET issue. Broadcasting using a @rolfbjarne Can we hope this bug will be re-evaluated? Can I open a new ticket? |
Reopening, I'll have another look and see if I can figure something out. |
Issue moved from dotnet/maui#26628
From @tpitman on Saturday, December 14, 2024 5:25:44 AM
Description
I have a MAUI ios and android app. I originally created it with net7 and then updated it to net8.
I use the following code to "ping" a device on my network that I also created:
This is how discover the IP address of my device. The I can connect to it.
This was working fine when I would build and deploy it from VS for Mac several months ago.
I then didn't work on it for several months.
Since that time I have started using VSCode on my mac. when I went to build it today, however, I was not able to debug it for some reason.
So I set up Visual Studio 2022 on a VM in Parallels on my mac.
I am able to build and debug, but now when I hit the udpClient.Send I get an exception that "no route is found".
When I search for that it talks about needing the multicast entitlement from Apple for my app.
If that is the case why did it used to work? Posts about that have been around for a long time...
The first time I run my app after initial installation the app does ask for permission to search for device on the local network and I Allow it.
It doesn't ask again unless I remove the app from the phone first.
I tried updated the app to net9 to see if that would make a difference and it doesn't.
I then posted a question on the Microsoft Answer site here:
https://learn.microsoft.com/en-us/answers/questions/2127840/multicast-udp-packets-stopped-working?comment=answer-1885404&page=1#comment-1860593
Some answered that it was because I didn't have the proper Entitlements.plist with the entry about multicast. I didn't think that was it because it wasn't there when it was working and that entitlement has been around a while.
I didn't have any other ideas, so I contacted apple and requested permission to have that capability on this app.
They granted it and I added the proper entitlement to the file and created a new provisioning profile.
This still gave the exact same error at the exact same place.
So I think this is a bug or change that I need help with.
Please help.
Steps to Reproduce
Link to public reproduction project repository
No response
Version with bug
9.0.21 SR2.1
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
8.0.40 SR5
Affected platforms
iOS
Affected platform versions
No response
Did you find any workaround?
No
Relevant log output
The text was updated successfully, but these errors were encountered: