首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ASIHTTPRequest超时

ASIHTTPRequest超时
EN

Stack Overflow用户
提问于 2011-05-03 06:07:34
回答 1查看 6K关注 0票数 2

你好,我正在使用ASIHTTPRequest向服务器发送一些值。一切正常,直到昨天requestFinished不能工作。(当应用程序在服务器上发送请求时,一个活动指示器和一个添加到主视图中的新视图被添加到主视图中,当请求完成时,将删除这些视图)。我添加了requestFailed来测试是否失败,并得到以下错误:

3438:207 Error Domain=ASIHTTPRequestErrorDomain Code=2 "The request timed out“UserInfo=0x5ad25c0

这很奇怪,因为昨天同样的代码运行得很好。我确信他们没有在服务器端做任何改变。

代码如下:

代码语言:javascript
复制
- (IBAction)convert:(id)sender{

//Get the email from the textfield
NSString *email1 = email.text;

//Save the last used email to load it on the next app launch
[[NSUserDefaults standardUserDefaults] setValue:email1 forKey:@"email"];

//Get the current URL from webview
NSString *currentURL= webView.request.URL.relativeString;

lbl.text = currentURL;

//Count the length of Label
int strL= [lbl.text length];

//The url that the requests will be send.
NSURL *url = [NSURL URLWithString:@"the website"];

//Indicator and its view are loading on the screen
[ind startAnimating];
[self.view addSubview:indView];


//ASIHTTPRequests   

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];

NSString *watch = [lbl.text substringWithRange:NSMakeRange(23,strL-23)];
NSString *link = [NSString stringWithFormat:@"http://youtube.com/%@",watch];

[request setShouldRedirect:YES]; 
[request setPostValue:watch forKey:@"url"];
[request setPostValue:email1 forKey:@"email"];
[request setPostValue:format forKey:@"format"];
[request setPostValue:quality forKey:@"quality"];
[request setDelegate:self];
[request startAsynchronous];

NSLog(@"%@ %@ %@ %@",watch,email1,format,quality);

click=NO;

},这是requestFinished:

代码语言:javascript
复制
- (void)requestFinished:(ASIFormDataRequest *)request{
NSString *responseString = [request responseString];
NSLog(@"%@",responseString);
NSLog(@"%@",lbl.text);
NSLog(@"requested finished");
[ind stopAnimating];
[indView removeFromSuperview];
[setView removeFromSuperview];

}

EN

回答 1

Stack Overflow用户

发布于 2011-07-19 22:20:53

您是否尝试增加请求的超时值?默认情况下是10秒,您可以在startAsynchronous调用之前将其放大:

代码语言:javascript
复制
[request setTimeOutSeconds:60];
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5863005

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档