Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSURLConnection and keep-alive

I have a small bug in my client app that uses NSURLConnection. I have tracked it down to an unexpected connection keep-alive that seems to confuse the web server (probably a bug on the server side). The workaround would be to force-close all outstanding connections at a certain point. Can I do this somehow with NSURLConnection, i.e. something like

[NSURLConnection closeAllIdleConnections];

like image 927
Krumelur Avatar asked Aug 29 '10 20:08

Krumelur


People also ask

What is the use of Keep-Alive timeout?

The keep alive timeout on the Message Processor allows a single TCP connection to send and receive multiple HTTP requests/responses from/to the backend server, instead of opening a new connection for every request/response pair.

Should I use Keep-Alive?

Enabling Keep-Alive is a great way to optimize your website as it helps improve speed and performance, ensuring faster load times and higher efficiency. By turning the Keep-Alive header on, the client and server can reuse a single TCP connection for a number of requests and responses.

What is client Keep-Alive?

The Client Keep-Alive mode enables the Citrix ADC appliance to process multiple requests and responses using the same socket connection. The feature keeps the connection between the client and the appliance (client-side connection) open even after the server closes the connection with the appliance.


1 Answers

ASIHTTPRequest has an expirePersistentConnections method. It may do what you're looking for.

It's not a drop-in replacement for NSURLConnection, but it's not too hard to port code from NSURLConnection to ASIHTTPRequest.

like image 112
Kris Markel Avatar answered Oct 14 '22 15:10

Kris Markel