Skip to content
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 #26628

Closed
tpitman opened this issue Dec 14, 2024 · 1 comment
Closed

Multicast UDP Packets Stopped Working on iOS MAUI App #26628

tpitman opened this issue Dec 14, 2024 · 1 comment
Labels
platform/iOS 🍎 potential-regression This issue described a possible regression on a currently supported version., verification pending t/bug Something isn't working

Comments

@tpitman
Copy link

tpitman commented Dec 14, 2024

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:

try
{
  using (UdpClient udpClient = new UdpClient(new IPEndPoint(IPAddress.Any, 12345)))
  {
    var cts = new CancellationTokenSource(5000);
    UdpReceiveResult

    #pragma warning disable CS4014 
    Task
    {
      receiveResult = 
      if
        cts.Cancel
    })
    #pragma warning restore CS4014 

    udpClient.Send(sendbuf, "255.255.255.255", 12345);

    while
      await

    if (receiveResult.HasValue)
    {
      string
      if (response.StartsWith("IP:") && response.Split(".").Count() == 4)
        deviceIp = response.Substring(3);
    }
  }
}
catch (Exception e)
{
  Console.WriteLine($"Exception: {e.Message}");
}

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

  1. Create MAUI net7.0 app
  2. Implement UDP Client Send call to broadcast on IP 255.255.255.255
  3. Upgrade to net8.0 and then net9.0
  4. Notice you get the "no route is found" error

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

@tpitman tpitman added the t/bug Something isn't working label Dec 14, 2024
@jfversluis
Copy link
Member

This issue was moved to dotnet/macios#21814

@dotnet dotnet locked and limited conversation to collaborators Dec 16, 2024
@samhouts samhouts added platform/iOS 🍎 potential-regression This issue described a possible regression on a currently supported version., verification pending labels Dec 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform/iOS 🍎 potential-regression This issue described a possible regression on a currently supported version., verification pending t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants