URLSessionConfiguration's httpMaximumConnectionsPerHost not working in iOS 10?

In a production app, I am setting the httpMaximumConnectionsPerHost property to 1 on a URLSessionConfiguration object when creating a URLSession. This allows me to queue a number of downloads, but only download 1 file at a time. Recently I noticed that all queued files download simultaneously on iOS 10 devices.


Has anyone else noticed this change? Is this intentional or a bug?


Note: I am setting the value of httpMaximumConnectionsPerHost both before and after creating the session, because of a post I found months ago that suggested that some properties of URLSessionConfiguration must be set after creating a URLSession in order for them to take effect.


    let configuration = URLSessionConfiguration.background(withIdentifier: sessionIdentifier)
    configuration.httpMaximumConnectionsPerHost = 1
   
    session = URLSession(
      configuration: configuration,
      delegate: self,
      delegateQueue: nil
    )
   
    session.configuration.httpMaximumConnectionsPerHost = 1

unfortunately our server can process 1 request at a time.

One request at a time? Or one connection at a time?

This matters because there hasn’t been a one-to-one mapping between requests and connections since HTTP 1.1 was introduced. And it’s even more important in HTTP/2 because that multiplexes all requests over a single connection.

IMPORTANT httpMaximumConnectionsPerHost is expected to control the number of simultaneous connections to a host, not the number of simultaneous requests.

Which brings me back to the question from my last post on this thread: Is this server HTTP/2?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

In my case the server is HTTP/3 (QUIC). My server* also can also only process 1 request at a time. How do I limit the concurrent request count for the session?

* actually, it's Google Cloud Storage, and it can only handle 1 request at a time per file, which applies if you're using chunked uploads to upload a large file.

How do I limit the concurrent request count for the session?

NSURLSession has no specific support for this. The only option I can see is for you to keep track of which requests are in flight and delay sending a request that targets file X if an existing request for file X is in progress.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Wild. Relaunching the app to queue up new requests is going to increase battery usage. Any chance this will be fixed in a later release of iOS?

Wild.

Honestly, I think the server-side behaviour here is the ‘wild’ thing. This is not how HTTP works in general.

Any chance this will be fixed in a later release of iOS?

If you’d like to see support for this added in the future, I encourage you to file an enhancement request with a very clear statement of your requirements. As I said above, this server-side behaviour is kinda weird and so it’s important to clearly explain what you need and why you need it.

Please post your bug number, just for the record.

Relaunching the app to queue up new requests is going to increase battery usage.

This suggests that your primary concern is NSURLSession background sessions. If so, make that clear in your ER.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

URLSessionConfiguration's httpMaximumConnectionsPerHost not working in iOS 10?
 
 
Q