runtime: [iOS] Error The Internet connection appears to be offline.

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.

{System.Net.Http.HttpRequestException: The Internet connection appears to be offline.
 ---> Foundation.NSErrorException: Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={_kCFStreamErrorCodeKey=50, NSUnderlyingError=0x3026e07e0 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_NSURLErrorNWPathKey=unsatisfied (Local network prohibited), interface: en0[802.11], ipv4, uses wifi, _kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <4B22EF41-B5E1-4278-8A9B-DE62658BEFB6>.<7>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <4B22EF41-B5E1-4278-8A9B-DE62658BEFB6>.<7>"
), NSLocalizedDescription=The Internet connection appears to be offline., NSErrorFailingURLStringKey=http://192.168.x.xx/m/d/ApiSettings/GetApiVersionInfo, NSErrorFailingURLKey=http://192.168.x.xx/m/d/ApiSettings/GetApiVersionInfo, _kCFStreamErrorDomainKey=1}
   --- End of inner exception stack trace ---
   at System.Net.Http.NSUrlSessionHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSUrlSessionHandler.cs:line 544
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   at JMoApp.Utilities.HttpUtilities.<GetResponseAsync>d__6`1[[JMoApp.Models.ApiVersionInfo, JMoApp, Version=2024.1.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() in C:\Code\My App \Utilities\HttpUtilities.cs:line 180}

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

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 1
  • Comments: 20 (5 by maintainers)

Most upvoted comments

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!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

Same issue here: MAUI is getting even more frustrating than Xamarin…and I said everything! Wake up, Microsoft!