Re: Now URL connection delegate isn't called at all
Re: Now URL connection delegate isn't called at all
- Subject: Re: Now URL connection delegate isn't called at all
- From: "Van Tol, Ladd" <email@hidden>
- Date: Fri, 23 Mar 2012 18:56:43 +0000
- Thread-topic: Now URL connection delegate isn't called at all
Have you considered driving CFNetwork directly with your own threads/operation queues?
You have to spin a run loop, but it avoids a lot of thread-to-thread bouncing that occurs in NSURLConnection.
- Ladd
On Mar 21, 2012, at 3:23 PM, Jens Alfke <email@hidden<mailto:email@hidden>> wrote:
Getting further into testing my NSOperationQueue-ified code on iOS (after working around the problem I reported earlier today), I’m finding that the NSURLConnection delegate methods are not being called at all. Ever. Which is kind of a showstopper, and I’ve run out of ideas for debugging/troubleshooting, since there isn’t much visibility into what CFNetwork is doing behind the scenes. To recap:
I’ve created a global NSOperationQueue to serialize access to the code that runs TouchDB, a NoSQL database, since the code is not thread-safe.
This code ends up starting asynchronous NSURLConnections to communicate with other servers. I’m setting the connection’s queue to my queue so the delegate methods will still be called:
_connection = [[NSURLConnection alloc] initWithRequest: _request delegate: self
startImmediately: NO];
[_connection setDelegateQueue: [NSOperationQueue currentQueue]];
[_connection start];
Yes, I’ve verified that +currentQueue returns my queue, since it’s being invoked from it.
On Mac OS X 10.7.3, everything is working fine.
On iOS 5.1, the connection object is created and started, but no delegate method ever gets called, nor does the connection ever get cancelled or released. So something is Very Wrong Indeed.
The rest of the app is running fine; the main thread is alive and handling events. The internal CFNetwork thread is idle. All other threads are idle, and I can’t find any thread associated with my queue. The queue object is still around, and has no operations queued in it.
Any ideas? I’d hate to have to back out all of this refactoring and go back to messing around on the CFNetwork thread, but if I can’t make this work on iOS I’m going to have to do just that.
—Jens
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden<mailto:email@hidden>)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
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