AFNetworking simultaneous requests

450 views Asked by At

I'm using AFNetworking for my app and I have some JSON calls I execute. In the 'background' I have a file download running. I would like to execute that one call specifically (a 100 MB file download) in the background, so that my JSON calls do not wait on the file download to complete.

The file download is taking about 5 MB/s bandwidth, so I'm not sure if the download is clogging up my bandwidth or the JSON calls are just idling until the download completes.

I tend to think that the latter is happing, and therefore I would like to know how to tell AFNetworking to run two calls simultaneously.

What I have tried:

  • Create a AFHTTPRequestOperation without it's manager, and fire it in a different NSOperationQueue
  • Using a synchronous call in a separate thread with NSData dataWithContentsOfUrl:
  • Using a different library just for the download (ASIHTTPRequest)
  • Using AFDownloadRequestOperation

But all without any success.

Is there any way I can make those two calls run simultaneously / run the download in the background on lower prio?

Thank you in advance.

1

There are 1 answers

2
Ramon On

The bandwidth was not an issue. AFNetworking was also able to run two calls simultaneously.

The issue was that the server where I was connecting to did not end / save the session for the download. This means the calls were not stateless, and the server was waiting for the download to complete before returning the other JSON calls.

We have fixed this by closing the session for the download.