错误:错误域= NSURLErrorDomain代码= -1001“请求超时。” [英] Error: Error Domain=NSURLErrorDomain Code=-1001 "The request timed out."

查看:5524
本文介绍了错误:错误域= NSURLErrorDomain代码= -1001“请求超时。”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Xcode 6.1,iOS 8.1中的应用程序;该应用程序工作完全正常,直到2天,但今天,当我执行它时,我在网络服务&错误打印在下面。

I am working on an application in Xcode 6.1, iOS 8.1; the application was working completely fine till 2 days before, but today as I executed it I got an error in the web service & the error is printed below.


错误:错误域= NSURLErrorDomain代码= -1001请求时间为
out。 UserInfo = 0x7c6899b0 {NSErrorFailingURLStringKey =,
NSErrorFailingURLKey =,NSLocalizedDescription =请求时间
out。,NSUnderlyingError = 0x7c688f60请求超时。}

Error: Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo=0x7c6899b0 {NSErrorFailingURLStringKey=, NSErrorFailingURLKey=, NSLocalizedDescription=The request timed out., NSUnderlyingError=0x7c688f60 "The request timed out."}

我曾使用AFNetworking 2.x和以下代码片段进行网络通话:

I had used AFNetworking 2.x and following code snippet to make network call:

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes=[manager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];

[manager POST:<URL>
   parameters:<parameters>
      success:^(AFHTTPRequestOperation *operation, id responseObject) {

          NSLog(@"JSON: %@", responseObject);
          NSError *error = nil;
          NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:&error];
          if (error) {
              NSLog(@"Error serializing %@", error);
          }
          NSLog(@"Dictionary %@", JSON);
          NSLog(@"Success");
      }
      failure:^(AFHTTPRequestOperation *operation, NSError *error) {
          NSLog(@"Error: %@", error);
      }]; 
}

更新:我已经退出/重新启动了iOS Simulator.app,重置内容&设置,但没有任何效果。

UPDATE: I had done quit/relaunched the iOS Simulator.app, reseted content & settings, but nothing worked.

推荐答案

代码中没有问题。我想内部的模拟器无法连接到互联网,这就是为什么在提供各种超时间隔后无法连接到服务器的原因。但是当我执行另一天时它完全没问题。感谢@Andrew Jaffee帮我找到了这个问题。

There was no issue in the code. I guess the simulator internally was not able to connect to the internet, so that is why it was not able to connect to the server after providing various timeout intervals. But it worked completely fine when I executed another day. Thanks to @Andrew Jaffee for helping me to find this issue.

这篇关于错误:错误域= NSURLErrorDomain代码= -1001“请求超时。”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆