Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)"如何解决

我的完整报错信息: Task <0568A3A0-A40C-42A8-9491-2FC52D71EFFF>.<4> finished with error [-1009] Error Domain=NSURLErrorDomain Code=-1009 "似乎已断开与互联网的连接。" UserInfo={_kCFStreamErrorCodeKey=50, NSUnderlyingError=0x107db5590 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=50, _NSURLErrorNWResolutionReportKey=Resolved 0 endpoints in 1ms using unknown from cache, _NSURLErrorNWPathKey=unsatisfied (Denied over Wi-Fi interface), interface: en0[802.11], ipv4, dns, uses wifi}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <0568A3A0-A40C-42A8-9491-2FC52D71EFFF>.<4>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask <0568A3A0-A40C-42A8-9491-2FC52D71EFFF>.<4>" ), NSLocalizedDescription=似乎已断开与互联网的连接。, NSErrorFailingURLStringKey=https://sharkserver.dypc.top/shark_user/login, NSErrorFailingURLKey=https://sharkserver.dypc.top/shark_user/login, _kCFStreamErrorDomainKey=1} 请求失败:似乎已断开与互联网的连接。

以下是问题的具体描述 我的A手机(15pro max 版本18,6,1) 使用xcode直接在A手机上运行我的程序 尝试发起post请求的时候得到了该报错。 我做了以下尝试 1.检查了A手机网络,一切正常,浏览器和其他app均可正常访问网络 2.检查了A手机上我的app权限,确认我因为为我的程序打开了无线网络和蜂窝流量 3.重启A手机,还原A手机网络设置,还原A手机所有设置,重启mac电脑 以上做法均无效,依旧报上面的错误

4.然后我尝试使用B手机(iPhone13 版本18.5)安装该程序 ,B手机可以正常运行并成功发起post请求,证明我的代码没有问题 5.我将代码上传至testfight 然后使用A手机下载testfight里的该程序 ,程序可以成功发起post请求没有任何错误,我再次使用xcode运行该程序到真机,又得到了Code=-1009错误 无法发起post请求

Sadly, I don’t read Chinese, so I’m responding based on a machine translation of your post.

Error -1009 is NSURLErrorNotConnectedToInternet. This can have a wide variety of causes, so it’s hard to track down exactly what’s going on here. However, it’s certainly weird that:

  • You’re consistently seeing this failure on phone A but not phone B.
  • Phone A works when you install your app with TestFlight.

Your full error message contains a useful titbit:

unsatisfied (Denied over Wi-Fi interface)

This is very solid evidence that your app’s connection is being blocked by NECP. For some general background on NECP, see A Peek Behind the NECP Curtain.

Notably NECP is blocking your access to Wi-Fi. That’s unusual because on most phones NECP only limits access to WWAN. I’m presuming that your phone was bought in China, and thus has the ability to limit an app’s access to WWAN and Wi-Fi.

When NECP goes wrong my usual recommendations are:

  1. Restart the device.
  2. Reset network settings.

You’ve tried both of these things and they didn’t help, which is actually quite surprising.

Have you tried deleting your app from the phone? Do this using the Home screen.

Also, if you put the same code into a small test app, created from Xcode’s iOS > App project template, does it have the same problem on phone A?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)"如何解决
 
 
Q