我正在开发一个iOS应用程序,它应该将传感器收集的数据发送到服务器。但是我只能在1分钟之后发送数据,因为我收到了以下错误:
submit error = Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x1469a9820 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "The request timed out." UserInfo={NSErrorFailingURLStringKey=http://xyz/abc/, NSErrorFailingURLKey=http://xyz/abc/, _kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4, NSLocalizedDescription=The request timed out.}}, NSErrorFailingURLStringKey=http://xyz/abc/, NSErrorFailingURLKey=http://xyz/abc/, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.}
以下是尝试发送数据的代码段:
-(void)postData:(NSString*)postTo withParameters:(NSDictionary*)parameters withHeaders:(NSDictionary*)headers{
[[UNIRest post:^(UNISimpleRequest *request) {
[request setUrl:[NSString stringWithFormat:@"%@%@", BASE_URL, postTo]];
[request setHeaders:headers];
[request setParameters:parameters];
}] asJsonAsync:^(UNIHTTPJsonResponse* response, NSError *error) {
if (error) {
NSLog(@"submit error = %@", error);
return;
}
else
{
NSLog(@"submit to %@ success", [NSString stringWithFormat:@"%@%@/", BASE_URL, postTo]);
}
}];
}
NSDictionary* headers = @{@"accept": @"application/json"};
for (int i = 0; i < sensorDataLength; i++) {
SensorData *Obj = [SensorArray objectAtIndex:i];
NSDictionary* parameters = @{@"x": [NSString stringWithFormat:@"%f", Obj.xAxis], @"y": [NSString stringWithFormat:@"%f", Obj.yAxis]};
[self postData:@"abc/" withParameters:parameters withHeaders:headers];
}
如何将超时间隔延长60秒? 任何帮助将非常感激。
答案 0 :(得分:0)
<强>超时强>
您可以设置自定义超时值(以秒为单位):
Dim strfilee As String
mydir = ":tmp"
strpath = mydir & ":"
strfilee = Dir(strpath) <--- Failing on this line
''''Loop through each file in the folder to find the one with the OS parameters
i = 0
Do While Len(strfilee) > 0
cellplace = "A" & i
If Right(strfilee, 11) = "params.pptx" Then
lspace = InStr(1, strfilee, "_", vbTextCompare)
target_name = Trim(Left(strfilee, lspace - 1))
sc_file_name = "tmp" & ":" & strfilee
With ActivePresentation
number_slides = .Slides(.Slides.Count).SlideNumber
End With
ActivePresentation.Slides.InsertFromFile sc_file_name, number_slides
End If
strfilee = Dir
i = i + 1
Loop
默认情况下,超时为60。