Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASIHTTPRequest synchronously

I have an iPhone app which uses ASIHTTPRequest to communicate to a REST service on my server. When I'm running on the simulator, it works just fine, but when I get onto the phone itself, I get weird behavior.

The very first time I click the button that initiates the request, I get the results back immediately, and all is fine. From that point on, when I click the button to initiate the connection it takes about 2-3 minutes to connect. It almost seems like the ASIHTTPRequest that I kicked off first (and from which I've already received the correct results) has not completed. Is there some sort of magic I need to use to terminate the original request before starting the next one? I assumed that since the -start method returned, and I have results from the server that the original request was completed and I could start another.

Any ideas?

Thanks

--Steve

like image 553
Steve Avatar asked Feb 28 '23 18:02

Steve


1 Answers

Steve - What you've described is a common problem that will occur if the requests are attempting to keep a persistent connection. Try this out:

[request setShouldAttemptPersistentConnection:NO];
like image 66
amehta Avatar answered Mar 11 '23 09:03

amehta