gpt4 book ai didi

iphone - sendAsynchronousRequest 在 iPhone 上遇到超时错误

转载 作者:行者123 更新时间:2023-11-29 04:24:20 26 4
gpt4 key购买 nike

我的应用程序允许用户拍照并将其上传到 PHP 服务器。我使用 sendAsynchronousRequest 调用将数据(带有照片文件的表单)发送到服务器。调试时,所有这些调用在我的 iPad 2 上都运行良好。但是当我在iPhone 4S上调试它时,其中一些出现错误,错误代码为-1001,代表超时错误。这两天我尝试了千百次寻找其根本原因,但还是找不到。

有人遇到过类似的情况吗?或者知道为什么吗?

我得到的唯一线索是,如果请求数据中有多个文件(原始照片文件和调整大小的缩略图文件),它将收到超时错误。与请求(照片文件)大小有关吗?或文件号码?

最佳答案

我使用这个简单的方法处理了失败的 ASIHTTP 请求。

- (void)requestFailed:(ASIHTTPRequest *)request {

NSError *error = [request error];

if([error code] == ASIRequestTimedOutErrorType ) {

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Error"
message:@"Connection Timed out"
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
return;
} else if ( [error code] == ASIConnectionFailureErrorType) {

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Error"
message:@"Connection Failiure"
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
return;

}
}

您还可以在请求中设置连接超时就像

[request_ setTimeOutSeconds:50.0];

这将等待 50 秒并显示连接超时错误。

关于iphone - sendAsynchronousRequest 在 iPhone 上遇到超时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12567300/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com