How can I get a single threaded network call in ObjC on iOS?
How can I get a single threaded network call in ObjC on iOS?
- Subject: How can I get a single threaded network call in ObjC on iOS?
- From: Jim Adams <email@hidden>
- Date: Tue, 28 Jun 2016 19:52:15 +0000
- Thread-topic: How can I get a single threaded network call in ObjC on iOS?
I have an application that has the requirement that the accesses to the server be single threaded, i.e. the second request cannot go through until the first request has completed. I am using NSURLSession and NSURLSessionDataTask. I have set the Maximum Concurrent Host number in the configuration to 1 but I have seen evidence that there are simultaneous requests going up to my servers.
Actually I don’t think they are truly simultaneous, just that the completion handler doesn’t finish before the next request goes out. Is there a way to make the next request wait until the completion block is exited?
My evidence comes from looking in the server logs. I have 3 servers in AWS behind an ELB. If I am able to get the cookies back from the server before sending the next request then my request will go to the same server that the last request went to. If I don’t wait then then the request goes to a random server. If I watch the logs I can see the requests come in on multiple servers.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden