-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
TodoREST Sample Project “HttpRequestException: The Internet connection appears to be offline.” “Local network prohibited” on iOS 16 #12731
Comments
@mdolfin hi there - are you using http or https? @rolfbjarne anything come to mind here with regard to iOS 16 differences? |
Hi @mdolfin. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
You can try and see if this is related to App Transport Security by setting the
|
@rachelkang I encounter the same error regardless of if I try to use http or https. I have also tried setting the NSAllowsArbitraryLoads key in the Info.plist before posting this issue with no progress, but I will look at the links from rolfbjarne and try again and respond with what I find. |
It appears not to be related to App Transport Security. Thank you for the info @rolfbjarne. If I understand correctly, replacing the NSAllowsLocalNetworking key with setting NSAllowsArbitraryLoads to true will completely disable App Transport Security (ATS) for all domains for the TodoREST sample. I have done that with no affect on the reported issue. Thank you. Any other ideas? |
A couple of things to try to figure out where the network connection stops:
Do you get the same error if you use the wrong port in the app? Or alternatively not start the server at all. This will show if there's an actual connection made to the server. What if you a random hostname from the internet instead (say www.google.com), do you get the same error then? Maybe there's a difference between a local network and internet somehow. |
Got some clues from that testing, @rolfbjarne, thank you. It seems to be behaving as though the local network permissions granted in iOS settings are being ignored on the device running iOS 16 that’s giving me the trouble. I get a 404 Not Found when I use a random, valid hostname or IP from the internet. That is expected behavior, so the issue does appear to be isolated to local network. I can also connect the iPhone to a completely different local network from the one the app is configured to find the server on, and I get a timeout rather than encountering the error. This is expected behavior, too, which is more evidence it is isolated to the local network. I tried changing which local network I'm running the client and server on just to see if somehow the problem is isolated to the one network I've been testing on up until now. Exact same issue on that network. I can reproduce the exact same error when the server is not running. So, it's erroring out before making a connection to the server. I can also reproduce by changing the IP in the app to one that is on the same network but is not in use (as if the server machine is off), and I can reproduce when I change the port to the wrong port in the app. This error, BTW, is identical to the one I get the first time I run the sample app, before the user gives the app permission to use the Local Network in iOS. Even on the iOS 15 device (the one that works as expected), the first attempt to connect the server results in this very same error that's giving me trouble. But on the working device running iOS 15, subsequent attempts to connect to the server succeed as expected after the user has given permission to the app to use the local network. On the device updated to iOS 16, all attempts fail with the error even after permissions are given to the app in iOS settings. So, I assume the error is the normal error that we are supposed to get when the app doesn't have permission to use the local network. So, it appears to me to behave as if the local network permissions granted are being ignored on the iOS 16 for some reason. Any ideas? Thanks! |
This is a wild shot, but try changing the bundle identifier to see if a different bundle identifier works. iOS identifies an app by the bundle identifier, and if you change it, iOS thinks it's a completely different app, so any old settings/stuff that might be cached/stored on disk will not be used. Do you have another device with iOS 16 you can use to check if this problem is limited to a single device? After that I guess the next step would be to try to re-create the problem in an Xcode sample, and if so, report the issue to Apple. |
@rolfbjarne it's working now!?! Thank you so much for helping me think through this. I have no idea why it's working now, though. I haven't changed anything. I wasn't working on this issue at all today. I was working on my real project that needs to create and consume a REST service. I got an API started and some code to TEST consuming it, and it worked on my iPad (with iOS 15) of course. When I was done for the day, I decided to try running that project on my iPhone (the one with iOS 16 giving me trouble), and it worked to my surprise. At first I thought you might have been right about the bundle identifier since I got it working in a separate project with a different bundle identifier. So, I decided to reproduce the issue one more time with the TodoREST sample and then try to fix it by changing the bundle identifier, but I never got the chance to reproduce the error because somehow it is just working now! It's still a mystery, I guess, but this can be closed. In any case it sounds like you are pretty confident this issue had nothing to do with MAUI/Xamarin and the next steps would have been to take the issue to Apple. I very much appreciate your helping me think through this. Thank you! -Matt |
The problem is back. New info: The problem only happens using Hot Restart. There is not a problem using a Mac build host (except for that being painfully slow.) This is a different device now currently that I'm having the problem with. I got a new phone and have been using it for a couple of weeks. Suddenly, today, out of nowhere I receive the "Local network prohibited" error despite having changed nothing. It was working for weeks (on this very device). I deployed to the device several times this morning like normal while working on my project without error, and then suddenly I can not connect to my web API on the local network with this error every time as if I don't have permission granted to the local network. Of course I do have the permission in the iOS settings on the device. Same as before. This is the same weird issue. ONE THING THAT DOES WORK: Remote deploy to the device using a Mac build host does work. I can switch back and forth in testing both my app project and the TodoREST sample between deploying remotely using the Mac and deploying locally using Hot Restart and it fails every time, both projects using Hot Restart and works every time, both projects using the Mac. Hot Restart only seems to have the issue. Deleting the app doesn't work. Rebooting devices, restarting VS, cleaning, rebuilding, deleting bin and obj folders, changing the app name and bundle ID, nothing fixes it. I'm stuck again. Like I said, I can deploy using the Mac, but that is so painfully slow. |
This is rather puzzling. Would it be possible to zip up the working (remotely built) and non-working (hot restart version) app bundles that are installed on the device? |
Hi @mdolfin. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
Well, the issue disappeared again by Monday. I'll upload the working and not working bundles if/when this happens again. Thanks. |
The problem has returned again. What, exactly, would you like me to zip up? That is unclear to me. The .app file in the debug build output directory is incomplete. Is that normal? Where can I find the completed bundle with everything in it? Thank you. |
This will list the apps that have been built remotely on a Mac:
and the Hot Restart builds from Windows are in |
Hi @mdolfin. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate. |
I'll upload the working and not working bundles if/when this happens again. The issue disappeared on me again before I received the instructions on where to find the bundles to upload for you to look at. I have not encountered this issue for some time now since I deleted all the MAUI debug apps I had loaded on the device. I have a few devices I test with, and this issue has only ever affected the one iPhone and then the new iPhone that I set up using an iCloud backup of the original one that was giving me trouble. There were several demo, tutorial, and practice MAUI apps that I had built and deployed to the device using Hot Restart and then never cleaned up. I cleaned them up now on both devices and the issue hasn't returned for some time. I still have no idea what the issue is/was, but maybe it was related to one of those somehow. I will reopen this ticket if it happens again. |
I got the same issue on iPhone with iOS 16.3.1, but works good on iPad with iOS 15. |
Hello lovely human, thank you for your comment on this issue. Because this issue has been closed for a period of time, please strongly consider opening a new issue linking to this issue instead to ensure better visibility of your comment. Thank you! |
i got same problem (socketexception while Socket.Connect to a local network ip:port as #14224 , same error no route to host). and i found the debugger never works (between my pc and iphone), using visual studio on windows, connect a mac in vmware, and mac connect to a iphone for run testing, but the visual studio on windows could not debug the program, it appears never connected (application on iphone crash never trigger any thing, breakpoint never hit, exit application on iphone would not stop the 'debug session', and press the stop debug button could hang visual studio for a long time, and never take effect). visual studio on windows usually auto disconnected to the mac. and every time i run a build on visual studio(windows), it has a big chance failed, in some case, clean the project output, then rebuild could help. but mostly case i need reboot the mac, and restart the visual studio(windows), then run build again (could be success). today i try to re-install the maui workload on visual studio (windows), also re-install the visual studio on mac. but still not solve the debug and build issue. (is that a common situlation or just happens on my side?) |
@rolfbjarne @steveisok @emaf is this maybe something to do with Hot Restart and the way the IDE communicates? |
We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process. |
I wonder if it's related to this somehow: https://developercommunity.visualstudio.com/t/HttpClient-behavior-in-NET-MAUI-iOS-app/10304297 |
@rolfbjarne Could it be for some reason for Hot Restart we fail to merge the manifests and so the needed settings are missing on the final app bundle? |
It could be, in which case the xcframework fix might have fixed this as well. |
Hi @mdolfin. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version. You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
Verified this issue with Visual Studio Enterprise 17.7.0 Preview 3.0(net8). Not repro on iOS platform with sample project. |
Adding some data points: A percentage of users of my enterprise application in production are experiencing this intermittently.
I am trying to dig into it some more, which is proving tricky without knowing what changed for MAUI specifically in regard to iOS 16. |
Description
The TodoREST sample MAUI app project works on my old iPad not updated since iOS 15.3, but not on my iPhone on iOS 16.2 when configured to run against the included REST API project running on Windows on my local network. I have confirmed that the app has local network permission granted to it in the iOS settings. That is not the issue, despite what the error seems to be indicating.
Steps to Reproduce
Expected outcome: The sample app is able successfully complete requests against the API.
Actual outcome: All requests fail on iOS 16.
Link to public reproduction project repository
https://github.com/dotnet/maui-samples/tree/main/7.0/WebServices/TodoREST
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iOS 16
Did you find any workaround?
Using my iPad on iOS 15 for now.
Relevant log output
The text was updated successfully, but these errors were encountered: