Multiple NSURLConnections Question
I'm using an async NSURLConnection wrapper to make calls to my server. I'm using long-polling techniques to make a realtime response from another user happen as quickly as possible.
However I'm running into an issue regarding multiple connections that I can't quite solve.
With the nature of the server communication I can't just kill the NSURLConnection and expect all connected parties to act gracefully. So what I'm doing instead is using a seperate 2nd instance NSURLConnection to call up to the server and call a necessary method to terminate the 1st instance Connection. This works great on the first try. The 2nd try seems to act completely differently.
Here's how it looks in my log:
1. Connection 1 : Initiate Call 1
2. Call 1 Waiting on server Response
3. Connection 2 : Initiate Cancel for Call 1
4. Connection 1 : Responds with "Cancelled by User"
5. Connection 2 : Responds with "Success"
(now do it again)
6. Connection 1 : Initiate Call 2
7. Call 2 Waiting on server Response
8. Connection 2 : Initiate Cancel for Call 2
(nothing happens... next until a timeout occurs)
My server logs show zero activity from step 8. It looks as though the application is having trouble with too many connections and Step 8 literally waits on Step 6/7 to finish.
What am I doing wrong here?!?!?!?! I can't see it being an issue on the server because my Android client that's calling the same methods doesn't encounter this problem. This is something I've done on everything except for ios and for some reason the connectivity just isn't working the way I expect.
|