Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 获取的NSURLConnection最多60秒超时?_Objective C_Timeout_Nsurlconnection - Fatal编程技术网

Objective c 获取的NSURLConnection最多60秒超时?

Objective c 获取的NSURLConnection最多60秒超时?,objective-c,timeout,nsurlconnection,Objective C,Timeout,Nsurlconnection,我正在为我的项目使用RestKit,我的请求需要超时10-20分钟(600-1200秒) 我能够将超时时间从1秒更改为60秒,这项工作没有任何问题。但当我试图设置超过60秒(90-9999999)时,我在60秒后收到超时错误。RKRequest.m中有这样的代码: - (void)fireAsynchronousRequest { RKLogDebug(@"Sending asynchronous %@ request to URL %@.", [self HTTPMethod], [[

我正在为我的项目使用RestKit,我的请求需要超时10-20分钟(600-1200秒) 我能够将超时时间从1秒更改为60秒,这项工作没有任何问题。但当我试图设置超过60秒(90-9999999)时,我在60秒后收到超时错误。RKRequest.m中有这样的代码:

- (void)fireAsynchronousRequest {
    RKLogDebug(@"Sending asynchronous %@ request to URL %@.", [self HTTPMethod], [[self URL] absoluteString]);
    if (![self prepareURLRequest]) {
        // TODO: Logging
        return;
    }
    _isLoading = YES;

    if ([self.delegate respondsToSelector:@selector(requestDidStartLoad:)]) {
        [self.delegate requestDidStartLoad:self];
    }

    RKResponse* response = [[[RKResponse alloc] initWithRequest:self] autorelease];

    _connection = [[NSURLConnection connectionWithRequest:_URLRequest delegate:response] retain];


    [[NSNotificationCenter defaultCenter] postNotificationName:RKRequestSentNotification object:self userInfo:nil];
}
我在NSURLConnection init之前添加了一行:

[_URLRequest setTimeoutInterval:1200];
但在60秒后再次收到超时错误。RKResponse对象是NSURLconnection的委托。 因此,我发现在60秒后,RKResponce.m中的委托metod被调用(甚至我尝试在[\u URLRequest setTimeoutInterval:1200]之后初始化NSURLConnection对象):

奇怪的是,我不能使NSURLConnection的超时超过60秒

今天我创建了一个新项目来测试这个问题。我有以下代码:

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSURL *url = [NSURL URLWithString: @"http://5.9.10.68:8182"];
    NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL:url];
    [urlRequest setHTTPMethod:@"GET"];
    [urlRequest setTimeoutInterval:300.0];
    NSLog(@"timeout %f",urlRequest.timeoutInterval);

    NSURLConnection*  urlConnection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate: self];

}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {

    NSLog(@"Error request %@", error);

}
下面是日志:

2012-07-17 14:37:58.627F[76799:f803]超时300.000000
2012-07-17 14:39:14.488 f[76799:f803]错误请求错误域=nsurErrorDomain代码=-1001“请求超时。”用户信息=0x687a690{NSErrorFailingURLStringKey=http://5.9.10.68:8182/,n错误失败键=http://5.9.10.68:8182/,NSLocalizedDescription=请求超时,NSUnderlyingError=0x687a070“请求超时”。}

所以超时=75,但不是300。很奇怪。

试过这种方法吗

RKObjectManager *objectManager = [RKObjectManager objectManagerWithBaseURL:@"http://somewhere.com"];
objectManager.client.timeoutInterval = 600;

实际上,我的代码看起来像:
RKObjectManager*manager=[RKObjectManager ObjectManager WithBaseUrlString:aBaseURL];manager.client.timeoutInterval=300但我发现这不是RestKit问题。我还发现与此问题相关:
RKObjectManager *objectManager = [RKObjectManager objectManagerWithBaseURL:@"http://somewhere.com"];
objectManager.client.timeoutInterval = 600;