Maximum number of concurrent NSURLConnections to the same host?

前端 未结 2 388
南方客
南方客 2021-01-12 04:35

I\'m running in to an issue in an OS X app that creates multiple, persistent connections to the same host using NSURLConnection. I create a separate connection for different

相关标签:
2条回答
  • 2021-01-12 05:28

    You could break this limitation by using CFNetwork API (CFHTTPMessage).

    Here is the CFNetwork Programming Guide. https://developer.apple.com/library/mac/documentation/Networking/Conceptual/CFNetwork/Introduction/Introduction.html#//apple_ref/doc/uid/TP30001132

    BTW, if you decide to use CFNetwork, you'll need to work around the proxy and authenticate.

    Wish this could helped!

    0 讨论(0)
  • 2021-01-12 05:41

    I filed a Radar for something that seems like the same issue but on iOS. I found that you can't have more than 5 connections open at once. The connections don't have to be pointing to the same domain. Anything after that would be queued. So if you have 5 connections open to an extremely slow endpoint, any other connections will not go through.

    Radar: http://openradar.appspot.com/radar?id=2542401

    Apple's reply:

    This is the effect of our NSURLConnection connection cache. It is expected. We expect to address this type of configuration with new API.

    I asked if they could give me anymore information (does it vary? does the type of connection affect it?) and they said:

    Unfortunately, we can't give details about the connection limit behavior.

    User agents in general (Chrome, Firefox, Safari) use six simultaneous TCP connections per hostname, with potential one-offs.

    0 讨论(0)
提交回复
热议问题