NSURLConnection 的奇怪错误代码 4294966295

Weird error code 4294966295 for NSURLConnection

我在使用 NSURLConnection 时遇到异常错误:

没有日志,或者这里没有任何内容。我能得到的只是错误代码4294966295。知道那可能是什么吗?

我在我的设备上 运行 XCode7 和 iOS9。我已经禁用了 ATS。

4294966295 当被视为带符号的 32 位 int 时是 -1001。这是NSURLErrorTimedOut。您可以在 NSURLError.h.

中查找代码

根据你的问题

,我浏览了很多文章、网站和链接

App Transport Security (ATS) enforces best practices in the secure connections between an app and its back end. ATS prevents accidental disclosure, provides secure default behavior, and is easy to adopt; it is also on by default in iOS 9 and OS X v10.11. You should adopt ATS as soon as possible, regardless of whether you’re creating a new app or updating an existing one.

If you’re developing a new app, you should use HTTPS exclusively. If you have an existing app, you should use HTTPS as much as you can right now, and create a plan for migrating the rest of your app as soon as possible. In addition, your communication through higher-level APIs needs to be encrypted using TLS version 1.2 with forward secrecy. If you try to make a connection that doesn't follow this requirement, an error is thrown. If your app needs to make a request to an insecure domain, you have to specify this domain in your app's Info.plist file.

请阅读以下参考文献

NSURLDomainError

Transport Security

Apple Document

我在尝试通过端口 81 从设备到本地计算机上的 Web 服务器进行测试时遇到了这个确切的错误。尽管在模拟器中工作正常。我机器上的防火墙阻止了 81 端口,所以关闭防火墙对我来说很容易解决。