I have recently moved from NSURLConnection to NSURLSession i.e., I have replaced all implementations of NSURLConnection with NSURLSession. I have done this so that my code is up to date.
Everything works fine except that I now keep getting a lot of errors which were never there with NSURLConnection. For eg., I keep getting 1001, 1003, 1005 etc intermittently. I am pretty sure that the connection is good and strong. I do not go out of network too.
My implementation for NSURLSession is as follows:
NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
sessionConfiguration.timeoutIntervalForRequest = 60;
sessionConfiguration.timeoutIntervalForResource = 60;
sessionConfiguration.HTTPMaximumConnectionsPerHost = 10;
sessionConfiguration.HTTPAdditionalHeaders = @{@"Connection": @"Upgrade"};
_mySession = [NSURLSession sessionWithConfiguration:sessionConfiguration delegate:self delegateQueue:nil];
_responseData = [NSMutableData data];
And here is how I create the task:
NSURLSessionDataTask *myTask = [self.mySession dataTaskWithRequest:inURLRequest];
[myTask resume];
I would appreciate if anyone can help in this regards. :(
Thanks in advance.