ASIHTTP请求超时
你好 我正在使用 ASIHTTPRequest 向服务器发送一些值。一切正常,直到昨天 requestFinished 不起作用。 (当应用程序在服务器上发送请求时,活动指示器和添加到主视图的新视图以及请求完成时删除视图)。我添加了 requestFailed 来测试是否失败,并收到此错误:
[3438:207] Error Domain=ASIHTTPRequestErrorDomain Code=2 "The request timed out" UserInfo=0x5ad25c0
它很奇怪,因为相同的代码昨天工作正常。我确信他们没有在服务器端进行任何更改。
这是代码:
- (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;
} 这是请求完成:
- (void)requestFinished:(ASIFormDataRequest *)request{
NSString *responseString = [request responseString];
NSLog(@"%@",responseString);
NSLog(@"%@",lbl.text);
NSLog(@"requested finished");
[ind stopAnimating];
[indView removeFromSuperview];
[setView removeFromSuperview];
}
Hello
I am sending some values to the server using ASIHTTPRequest. All works fine until yesterday that the requestFinished didnt work. (when the app send the request on the server an activity indicator and a new view added to the main view and when the request finished is removing the views). I added requestFailed to test if is failed and I get this error:
[3438:207] Error Domain=ASIHTTPRequestErrorDomain Code=2 "The request timed out" UserInfo=0x5ad25c0
Its weird because the same code was working fine yesterday. I am sure that they didnt make any changes on the server's side.
this is the code:
- (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;
}
and this is the requestFinished:
- (void)requestFinished:(ASIFormDataRequest *)request{
NSString *responseString = [request responseString];
NSLog(@"%@",responseString);
NSLog(@"%@",lbl.text);
NSLog(@"requested finished");
[ind stopAnimating];
[indView removeFromSuperview];
[setView removeFromSuperview];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试增加请求的超时值?默认情况下为 10 秒,您可以通过在 startAsynchronous 调用之前执行此操作来使其更大:
Did you try to increase the timeout value on the request? By default it is 10 seconds, you can make it larger by doing this right before the startAsynchronous call: