I have an iOS app where I call same API too many times in a looping sense. viz. Call first API -> Get response, parse it -> save to local -> Call same API again ... and so on. So in this flow. Somewhere randomly a request gets times out and I get following logs :
Task <E49E4BD3-882E-4FFE-A6E1-75E28102CC20>.<7> load failed with error
Error Domain=NSURLErrorDomain Code=-1001 "The request timed out."
UserInfo={_kCFStreamErrorCodeKey=-2102,
NSUnderlyingError=0x600000f28ed0 {Error Domain=kCFErrorDomainCFNetwork
Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102,
_kCFStreamErrorDomainKey=4}},
_NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <E49E4BD3-882E-
4FFE-A6E1-75E28102CC20>.<7>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <E49E4BD3-882E-4FFE-A6E1-75E28102CC20>.<7>"
), NSLocalizedDescription=The request timed out.,
NSErrorFailingURLStringKey=https://api.domainname.com/getDataApi,
NSErrorFailingURLKey=https://api.domainname.com/getDataApi,
_kCFStreamErrorDomainKey=4} [-1001]
It works properly many times . The headers and parameters are correct. I have tried putting those request in NSOperationQueue , Dispatch group. But it works same. I have also tried with NSURLSession instead of Alamofire. No change. It happens frequently on iPhone X and rare on other devices. I am calling API too many times because the data is about 30-40 thousand records and each API returns 1000 records. Sometimes the first API fails sometimes after few hits. Its random. The internet connection is good at time of failure. Streaming, browsing works fine at same time. But the API gives request time out. Tried increasing timeout interval for request. There's no issue with parameters/headers I send because same api works fine some times and fails sometimes. Data returned is also same for all devices.