1

I'm using AFNetworking 2.5.2, and I have successfully implemented the usage of AFURLSession to handle background downloads. The issue is the following:

  • The downloads can be very small (a few Kbs) or quite large (more than 30 or 50 Mbs).
  • These downloads are actually SOAP envelope, with embedded files encoded in Base64. I know this is not ideal, files should be downloaded separately, but I don't have control on that part.
  • The web services I use have to transform all files to Base64 before giving an initial answer with the SOAP envelope. This means the bigger the files are, the longer it can take for the service call to initially respond.

So small downloads (let's say < 15 Mb) work fine. For bigger downloads, more specifically when the service takes more than 60 seconds to answer, I receive the following logs on my device:

Jun  2 15:27:08 Phonezon iap2d[6120] <Warning>: process xxx is now suspending
...
Jun  2 15:27:42 Phonezon nsurlsessiond[6810] <Notice>: SocketStream watchdog timer fired after 65.000000 seconds of inactivity. Timing out the connection.

The first log entry is expected, my background download starts from a background fetch request, then the app is suspended.

The second log entry occurs if the web service takes too long to give an initial answer.

I have tried changing various timeoutInterval parameters (configuration.timeoutIntervalForRequest, configuration.timeoutIntervalForResource, requestSerializer.timeoutInterval, urlRequest.timeoutInterval), without any effect. It seems as if the NSURLSession layer of iOS decides to kill my request after these 65 seconds.

Is there anything I can do to prevent this ? Please let me know if you need more detail.

ChenYilong
  • 8,543
  • 9
  • 56
  • 84
thomzon
  • 11
  • 2

0 Answers0