Open czuck opened 3 months ago
Could you please add any relevant code that you are using here? Preferably a reproduction project?
Trying to narrow down the issue, it only occurs if the url I'm sending the http request to is my local machine or local hyperV instance. I'm using ip addresses for both connections, but I can use an ip to a non-secure server on the network and do not get the issue. I do have NSAllowsArbitraryLoads set to true. I do have a 'try again' button that executes the exact same http request, and the second time it will often return successfully. This is also happening during the startup of my app.
Hi, I'm not the OP but basically facing the same issue. I've written a little sample project which can be found here. It's a REST API client which also uses HttpClient.SendAsync(requestMessage) to send a request to a URL of your choice.
I've tested this both on Android and iOS with physical devices. On Android (10) my request is successful and answered with 204 Not Content (as expected):
On iOS (17.4.1) the same request is failing with the same error as OP's:
I forgot to mention that my REST server runs on an internal network without any access to the Internet. Maybe this helps.
Verified this issue with Visual Studio 17.10 Preview 7.0 (8.0.21). Can repro it on Maui iOS platform. And in Xamarin iOS and Android. It worked fine.
/similarissues
Hi I'm an AI powered bot that finds similar issues based off the issue title.
Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
Tagging subscribers to this area: @dotnet/ncl See info in area-owners.md if you want to be subscribed.
Getting the same error with post
var response = await client.PostAsync(url,
new StringContent(
JsonConvert.SerializeObject(item),
Encoding.UTF8, MediaType), cancellationToken);
Does anyone got to solve the issue? I am facing the same issue.
In debug mode the api calls work fine. But in release after first install is not working, the user has to close the app and reopen it, then it keeps working fine.
Version 8.0.20
I have managed to reproduce this reliably. I am not sure if this is the same as the original problem.
We have multiple solutions that reference a core nuget package which is a MAUI class library and has all of our components and any shared resources (images / styles).
When there are multiple solutions installed on a single iOS device, with different versions of this nuget package, then I get the error.
If I uninstall all but one of the solutions, it starts working again.
I'm running into this and cannot get past it. It is only happening once deployed, testing it through TestFlight.
I can build the app in release mode with a developer provisioning profile, and it connects fine, but once I deploy it through the app store, it gives me "The Internet connection appears to be offline."
I am trying to connect to a local resource on the same network, which is using a self-signed TLS certificate (using ServerCertificateCustomValidationCallback
to validate it manually).
I can connect to our service fine through Safari, but not my app when deployed.
I've tried adding:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsLocalNetworking</key>
<true/>
</dict>
to Info.plist and using NSUrlSessionHandler.TrustOverrideForUrl
to manually approve the URL, but neither have helped.
dotnet --version 8.0.302
If anyone has any insight, it would be greatly appreciated. This is blocking my ability to publish the app and I am out of debugging ideas.
I'm running into this and cannot get past it. It is only happening once deployed, testing it through TestFlight.
I can build the app in release mode with a developer provisioning profile, and it connects fine, but once I deploy it through the app store, it gives me "The Internet connection appears to be offline."
I am trying to connect to a local resource on the same network, which is using a self-signed TLS certificate (using
ServerCertificateCustomValidationCallback
to validate it manually).
I can connect to our service fine through Safari, but not my app when deployed.I've tried adding:
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsLocalNetworking</key> <true/> </dict>
to Info.plist and using
NSUrlSessionHandler.TrustOverrideForUrl
to manually approve the URL, but neither have helped.dotnet --version
8.0.302
If anyone has any insight, it would be greatly appreciated. This is blocking my ability to publish the app and I am out of debugging ideas.
Hi MrZander,
Have you tried removing NSAllowsLocalNetworking and instead adding NSAllowsArbitraryLoads? Doing this, will disable the ATS security restrictions, which is not recommended, however is required if your network service does not meet them. You can read more here: https://developer.apple.com/documentation/bundleresources/information_property_list/nsapptransportsecurity/nsallowsarbitraryloads
Even with ATS turned off I believe you will still be prompted to grant permission to access local networks, if all is working as expected.
Please note, while this may be a solution, it is still not a solution when having multiple MAUI apps installed at once, as per my previous comment.
@deejcoder I get the same error message with NSAllowsArbitraryLoads
, but I only have one MAUI app installed.
It started working after I rebooted my device. I have no idea why, one of the most frustrating problems I've ever debugged.
My info.plist has only NSAllowsLocalNetworking
set to true
Description
This error has been reported but those reports have been closed and this is an issue in 8.0.20 but I can also recreate it with 8.0.14. When my app is not previously installed on my phone, I consistently get this error when calling HttpClient.SendAsync(requestMessage). Just before this call Connectivity.NetworkAccess is checked and is set to NetworkAccess.Internet. I will do a full rebuild and debug and repeat that process until the request is successfully returned. Once it works, it continues to work until I delete the app from the phone, at which point the issue reappears. It happens with both Debug and Release builds. I have tested doing a rebuild, if works (for the first time), I delete the app from the phone, re-deploy the same build and test and it does not work.
Steps to Reproduce
No response
Link to public reproduction project repository
No response
Version with bug
8.0.20 SR4
Is this a regression from previous behavior?
Yes, this used to work in Xamarin.Forms
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
17.4.1
Did you find any workaround?
keep rebuilding and debugging.
Relevant log output
No response