在 AFNetworking 中找不到具有指定主机名的服务器

2vi*_*on2 4 objective-c ios afnetworking afnetworking-2

AFnetworkingASIHTTPRequest我的应用程序中切换API以解决连接错误问题。

但是现在我在AFNetworking. 我该如何解决这个问题?

Printing description of error: Error Domain=NSURLErrorDomain Code=-1003 "A server with the
specified hostname could not be found." UserInfo=0x1553bab0
{NSErrorFailingURLStringKey=https://example.com/oauth/token,
NSErrorFailingURLKey=https://example.com/oauth/token, NSLocalizedDescription=A server
with the specified hostname could not be found., NSUnderlyingError=0x1553b2c0 "A server
with the specified hostname could not be found."} (lldb) 
Run Code Online (Sandbox Code Playgroud)

Moh*_*hit 5

基本上这是一个服务器端问题。当您的服务器没有响应或您的服务器看起来像处于睡眠模式时,就会发生此错误。

我也多次获取同样的问题。但是,就我而言,当我切换到另一个 WiFi 网络或打开/关闭 WiFi 时,它会自动解决。请尝试一下,让我们知道您的意见。

谢谢!

  • 我也得到完全相同的问题,它已经很长时间仍未解决。我不能只说这是服务器端问题,因为它适用于 Android 也适用于网站。我只有在 IOS 中有问题。如果是服务器端问题,能否请您给出提示。这与长时间打开连接,gzip 还是什么有关?请建议!! (2认同)