Re: Spoon-feeding NSURLConnection
Re: Spoon-feeding NSURLConnection
- Subject: Re: Spoon-feeding NSURLConnection
- From: Jens Alfke <email@hidden>
- Date: Thu, 28 Jun 2012 11:51:14 -0700
On Jun 28, 2012, at 10:33 AM, Mark Pauley wrote: Did you by chance turn on http pipelining with NSMutableURLRequest -setHTTPShouldUsePipelining? Make sure you set this to NO on your long-running requests.
No, I didn't turn that on.
You might just be hitting head of line blocking, which we can't really do anything about.
I don't think it's an unavoidable problem. At the point it gets stuck, CFNetwork has several idle sockets open to the server, and there's no reason it couldn't schedule the next request onto one of them. What it seems to have done instead is pre-scheduled the request onto the one socket that's indefinitely blocked on the hanging-GET. In other words, it's assigning requests to sockets too early.
There's also the data point that this problem isn't happening in Mac OS, even though (as far as I can tell) both platforms use the same number of sockets during the test. Mac OS just seems to be smarter about queuing the requests somehow. If you have long running requests, but still want pipelining for the rest of your short requests, you may be able to partition your pool as Quinn describes.
I've been adding code for that* and it seems to be working. It's not going to be bulletproof, though — it won't work with numeric hostnames ("127.0.0.1." doesn't parse) or if the URL I'm given has a hostname that already ends with a dot.
What we really need is a property on an NSURLRequest that says "put this on a dedicated socket".
—Jens
* Modifying an NSURL to append a "." to the hostname is surprisingly difficult/ugly to do. It would make a good puzzle for intermediate Cocoa coders. :-p |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden