1

I am using custom protocol where I create NSURLSession with defaultConfiguration. Here is my code -

`   
 NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];

config.timeoutIntervalForRequest = 10.0;
config.timeoutIntervalForResource = 10.0;
config.HTTPMaximumConnectionsPerHost = 2;
config.connectionProxyDictionary = proxyToUse;

[NSURLProtocol setProperty:@YES forKey:@"MyURLProtocolHandledKey" inRequest:mReq];

if(!_mySession) {
    _mySession = [NSURLSession sessionWithConfiguration:config
                              delegate:self
                         delegateQueue:nil];
}

`

When App is making hundreds of request, there is gradual increase in response time in serving requests from custom protocol. I can see maximum timeout of 60sec. There is no effect of these configuration parameters.

Mostafiz
  • 7,243
  • 3
  • 28
  • 42
sona
  • 11
  • 2
  • Without seeing the rest of your code, it's hard to say, but... are you sure these requests aren't all going into separate sessions? Also, bear in mind that a gradual increase in response time is exactly what you'd expect if you're limiting yourself to two active connections at a time. The other requests will queue up waiting for a chance to get sent. – dgatwood May 18 '16 at 21:26

1 Answers1

0

Some URLSessionConfiguration properties should be set up before configuration is used to create a new URLSession. For example to set up a timeoutIntervalForRequest you have to do the following:

let configuration = URLSessionConfiguration.default
configuration.timeoutIntervalForRequest = 2
let session = URLSession(configuration: configuration)
Avt
  • 16,927
  • 4
  • 52
  • 72