I'm using NSURLSession to send https requests using method dataTaskWithRequest. Currently, In each call I create the session object from scratch in the following way :
NSURLSessionConfiguration* configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
NSOperationQueue *operationQueue = [[NSOperationQueue alloc] init];
perationQueue.maxConcurrentOperationCount = 1;
NSURLSession* session = [NSURLSession
sessionWithConfiguration:configuration
delegate:[challengeDelegate alloc]
delegateQueue:operationQueue];
Than I use the this object with the send method :
NSMutableURLRequest *ns_req = [NSMutableURLRequest requestWithURL:reqUrl];
NSURLSessionDataTask *_dataTask =
[session dataTaskWithRequest:ns_req
completionHandler:^(NSData * _Nullable data,
NSURLResponse * _Nullable response,
NSError * _Nullable error) {...}
New server requirements that all requests are to be sent on the same tcp connection, So I wonder if it can be done by creating session only once (I keep it as class member) ?
But what happens the server will reset the connection (in case of timeout between 2 consecutive call or any other reason). How can I get indication for this event. Should I just set my session variable with a new NSURLSession object in order to refresh the object with new connection ?