12

We're currently dealing with a performance issues in our app, and we believe that some of these issues might be related to the fact that the app and the underlying AFNetworking network stack seems to ignore keep-alive on HTTP 1.1.

We got information from Apple that persistent connections are purged after 3, 6 or 30 seconds respectively, depending on iOS version and WiFi/WWAN connectivity, regardless of server-side keep-alive information.

While monitoring the connection handshakes on our servers, we noted the weird behavior that an SSL connection from our app on an iOS device is left open and not closed with a FIN packet. As soon as new request is made from the app, the left over connection from the previous request is THEN closed with a FIN packet and a new connection is created.

While we understand that iOS purges the connections to keep the battery consumption low, we wonder that it doesn't terminate the existing connection properly and defers that termination to the start of a new request.

Could someone explain this behavior, and suggest solutions to avoid expensive SSL handshakes in connections which are covered by keep-alive under regular conditions?

WarrenFaith
  • 57,492
  • 25
  • 134
  • 150
  • Which versions of iOS are affected? – Adam Apr 01 '13 at 12:51
  • 1
    Which WWDC sesstion? By the way, the persist connection is handled by CFNetwork layer. And as far as I know, there are no API to change the behavior. You can have a look at how ASIHttpRequest support persist connection.So this issue is not related to AFNetworking or NSURLConnection. And I guess most likely we have nothing to do. – Bob Cromwell Apr 02 '13 at 06:33
  • @Adam - As far as I know from iOS 8 its affected.Here is another question that is somewhat related to http://stackoverflow.com/q/29063803/730807 – Durai Amuthan.H Mar 16 '15 at 14:02

1 Answers1

0

I bumped into the same problem some weeks ago. The solution was to force webserver ignore keepalive http header from iOs device and close connection immediately.

German Saprykin
  • 6,631
  • 2
  • 29
  • 26
  • you mean to say you have configured the webserver in such a way that doesn't support keep-alive connections so the problem won't come – Durai Amuthan.H Mar 16 '15 at 13:57