cURL / Mailing Lists / curl-library / Single Mail

curl-library

Clear connection cache libcurl 7.44

From: risto via curl-library <curl-library_at_cool.haxx.se>
Date: Tue, 5 Jul 2016 13:19:51 +0000 (UTC)

Hi,
What are the possible ways to clear cURL connection cache? One way would be to close the current multi handle and open a new one. Are there some other options? I've got a situation where connection cache is kept through internet connection change (Wifi -> 3G for example). After network change cURL will try to reuse the connection from cache and will fail and open a new connection. The problem is that it takes ~20 seconds to understand that the connection was dead. Are there any ways to overcome this? I'd still like to reuse connections when possible. I could force requests with CURLOPT_FRESH_CONNECT after network change for some time but that's not ideal.
Regards,Risto
Here's the example cURL output for this problem:
2016-07-05 15:51:34.155 //First request* STATE: INIT => CONNECT handle 0x8604f8; line 1090 (connection #-5000)* Added connection 0. The cache now contains 1 members* timeout on name lookup is not supported*   Trying 54.175.219.8...* STATE: CONNECT => WAITCONNECT handle 0x8604f8; line 1143 (connection #0)* Connected to www.httpbin.org (54.175.219.8) port 80 (#0)* STATE: WAITCONNECT => SENDPROTOCONNECT handle 0x8604f8; line 1240 (connection #0)* STATE: SENDPROTOCONNECT => WAITDO handle 0x8604f8; line 1258 (connection #0)* STATE: WAITDO => DO handle 0x8604f8; line 1290 (connection #0)* STATE: DO => DO_DONE handle 0x8604f8; line 1337 (connection #0)* STATE: DO_DONE => WAITPERFORM handle 0x8604f8; line 1464 (connection #0)* STATE: WAITPERFORM => PERFORM handle 0x8604f8; line 1474 (connection #0)* STATE: PERFORM => DONE handle 0x8604f8; line 1632 (connection #0)* Curl_done* Connection #0 to host www.httpbin.org left intact
2016-07-05 15:52:04.741 //Second request* STATE: INIT => CONNECT handle 0x8604f8; line 1090 (connection #-5000)* Found bundle for host www.httpbin.org: 0x853d38* Re-using existing connection! (#0) with host www.httpbin.org* Connected to www.httpbin.org (54.175.219.8) port 80 (#0)* STATE: CONNECT => WAITDO handle 0x8604f8; line 1136 (connection #0)* STATE: WAITDO => DO handle 0x8604f8; line 1290 (connection #0)* STATE: DO => DO_DONE handle 0x8604f8; line 1337 (connection #0)* STATE: DO_DONE => WAITPERFORM handle 0x8604f8; line 1464 (connection #0)* STATE: WAITPERFORM => PERFORM handle 0x8604f8; line 1474 (connection #0)
2016-07-05 15:52:23.626 //Connection is dead - retry Recv failure: Connection was reset* Connection died, retrying a fresh connect* Curl_done* Closing connection 0* The cache now contains 0 members* Issue another request to this URL: 'http://www.httpbin.org/get'* STATE: PERFORM => CONNECT handle 0x8604f8; line 1608 (connection #-5000)* Added connection 1. The cache now contains 1 members* timeout on name lookup is not supported* Hostname www.httpbin.org was found in DNS cache*   Trying 54.175.219.8...* STATE: CONNECT => WAITCONNECT handle 0x8604f8; line 1143 (connection #1)* Connected to www.httpbin.org (54.175.219.8) port 80 (#1)* STATE: WAITCONNECT => SENDPROTOCONNECT handle 0x8604f8; line 1240 (connection #1)* STATE: SENDPROTOCONNECT => WAITDO handle 0x8604f8; line 1258 (connection #1)* STATE: WAITDO => DO handle 0x8604f8; line 1290 (connection #1)* STATE: DO => DO_DONE handle 0x8604f8; line 1337 (connection #1)* STATE: DO_DONE => WAITPERFORM handle 0x8604f8; line 1464 (connection #1)* STATE: WAITPERFORM => PERFORM handle 0x8604f8; line 1474 (connection #1)* STATE: PERFORM => DONE handle 0x8604f8; line 1632 (connection #1)* Curl_done* Connection #1 to host www.httpbin.org left intact

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-07-05