Ios5 正在忽略RestKit超时

Ios5 正在忽略RestKit超时,ios5,timeout,restkit,Ios5,Timeout,Restkit,我正在从我的iOS应用程序调用一个Web服务,返回该服务最多需要四分钟。我正在使用RestKit调用和加载对象。我发现,当请求花费很长时间时,我会在大约60秒后出现超时错误。我曾尝试将timeoutInterval设置为荒谬的值,但在~60秒后仍然超时 RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:HOSTNAME]; objectManager.client.requestQueue.sh

我正在从我的iOS应用程序调用一个Web服务,返回该服务最多需要四分钟。我正在使用RestKit调用和加载对象。我发现,当请求花费很长时间时,我会在大约60秒后出现超时错误。我曾尝试将timeoutInterval设置为荒谬的值,但在~60秒后仍然超时

RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:HOSTNAME];

objectManager.client.requestQueue.showsNetworkActivityIndicatorWhenBusy = YES;
objectManager.client.disableCertificateValidation = YES;

//timeout
objectManager.client.timeoutInterval = 1000;
以下是对该服务的呼叫:

- (void)loadData 
{

NSString *uid = [self retrieveFromUserDefaults:@"login_preference"];
NSString *pwd = [self retrieveFromUserDefaults:@"password_preference"];

if([uid isEqualToString:@""] || [pwd isEqualToString:@""]){
    [self stopSpinner];
    [self enableUserInterface:YES];
    UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Missing Settings" 
                                                    message:@"Please enter your login information in the settings."
                                                   delegate:nil 
                                          cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    return;

}


RKObjectManager* objectManager = [RKObjectManager sharedManager];
NSDictionary *params = [NSDictionary dictionaryWithObjects: 
                        [NSArray arrayWithObjects:uid, pwd, nil] 
                                                   forKeys:[NSArray arrayWithObjects:@"uid", @"pwd", nil]]; 

// Load the object model via RestKit    
[objectManager loadObjectsAtResourcePath:[@"/synchData" appendQueryParams:params] delegate:self];
}

我在后台线程中调用Web服务-该设计中是否有可能导致问题?我无法想象什么,比如iOS不让后台线程运行超过60秒?我就是想不出是什么问题


超时是从服务器获取响应所需的时间,还是从服务器获取整个响应所需的时间?我正在返回一个可能非常大的json响应—我需要在超时限制内返回整个内容,还是只需要在该限制内从服务器获得任何响应

我遇到了一个类似的问题,委托方法
requestDidTimeout:(RKRequest*)request
从未被调用。无论我在RKRequest或RKClient上设置超时

警告: 在对请求设置超时时,我看到请求没有遵守设置的超时 除非我也调用
[requestObject createTimeOutTimer]

然而,我在您的实现中注意到,您使用1000表示NSTimeInterval:您是说1000秒表示超时吗?如果您的意思是1秒=1000毫秒,请更改为1


RestKit上的默认超时为120秒,因此这很可能是NSURLConnection超时。

如果我了解您的问题,解决方案是:

- (void)request:(RKRequest *)request didFailLoadWithError:(NSError *)error

因此,当您遇到超时间隔问题时,将使用此方法捕获它。

长期以来,Restkit库(版本~=.4)只支持在单个位置添加
timeoutInterval

/**
An optional timeout interval within which the request should be cancelled.
This is passed along to RKRequest if set.  If it isn't set, it will default
to RKRequest's default timeoutInterval.
*Default*: Falls through to RKRequest's timeoutInterval
*/
@property (nonatomic, assign) NSTimeInterval timeoutInterval;
在RKEResponseLoader.h中

/**
The timeout interval, in seconds, to wait for a response to load.
The default value is 4 seconds.
@see [RKTestResponseLoader waitForResponse]
*/
@property (nonatomic, assign) NSTimeInterval timeout;

向我们展示您如何发送请求。超时是应用程序等待收到任何响应的时间,您不需要在这段时间内返回全部内容。谢谢-我添加了一点,这就是您的意思吗?我仔细检查了一遍,不管我的超时时间间隔是多少,它都会在60秒后消失。是的,这就是我的意思。我看不出你的代码有什么问题,你是如何捕获超时的?RestKit文档说默认超时设置为120秒,超时函数
将通过didFailLoadWithError:
返回RKRequestConnectionTimeoutError,因此如果您在
requestDidTimeout:
中捕捉到它,则可能会有其他机制调用它。您可能希望在捕获超时的方法中放置一个调试器,并检查调用堆栈以找到导致超时的确切原因,也许这将帮助您确定60s值的来源。我在didFailWithError中捕获它。我从未访问过requestDidTimeout,因为它从未从RestKit调用,因为我的RKRequestBackgroundPolicy为None。我想我在调试方面很差劲,因为当我进入我的didFailWithError时,我在堆栈中找不到任何东西来说明是什么导致它死亡。你能确认你使用的是最新版本吗?根据这一点,这个问题应该已经得到解决