curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: libcurl multi timeout after IP or routing table changes

From: Silas via curl-library <>
Date: Wed, 26 Jan 2022 08:34:24 -0300

On Wed, Jan 26, 2022 at 09:20:40AM +0100, Daniel Stenberg wrote:
> If you enable CURLOPT_VERBOSE for the attempt after the network change, does
> it reveal any details of what exactly it is that fails and thus make libcurl
> time out?

Hi. I just discovered I can only reproduce this behaviour when using HTTPS.
Maybe a openssl thing? The same program using plain HTTP can get through network

I just enabled CURLOPT_VERBOSE and I see things like this:

* Found bundle for host 0x7a8c9fd2a210 [can multiplex]
* Re-using existing connection! (#0) with host
* Connected to ( port 443 (#0)
* Using Stream ID: 3 (easy handle 0x7a8c9fcde800)
> GET / HTTP/2
accept: */*
* Operation timed out after 4999 milliseconds with 0 bytes received
* stopped the pause stream!
* Connection #0 to host left intact

Should it use the existing connection if I'm calling curl_easy_cleanup()?

> > I can provide you with a small C program and a 2 line shell script (to
> > change network configuration in a NetBSD or Linux box) to reproduce this
> > behaviour, if you want.
> Plese do. And tell us what libcurl version you're using for this.

Here is the C program. Below it there a small script I'm running to change
network configuration. It just pools each 5 seconds. For
testing purposes only one easy handle is created. It could easily be done with
easy interface only, but the idea here is to debug this behaviour on the multi

#include <assert.h>
#include <stdio.h>
#include <unistd.h>
#include <curl/curl.h>
int main(int argc, char *argv[]) {
        CURL *m;
        m = curl_multi_init();
        for (;;) {
                CURL *h = curl_easy_init();
                curl_easy_setopt(h, CURLOPT_URL, "");
                curl_easy_setopt(h, CURLOPT_TIMEOUT, 5);
                curl_easy_setopt(h, CURLOPT_VERBOSE, 1L);
                curl_multi_add_handle(m, h);
                int still_running = 0;
                curl_multi_perform(m, &still_running);
                while (still_running) {
                        curl_multi_perform(m, &still_running);
                        int msgs_in_queue;
                        CURLMsg *msg;
                        msg = curl_multi_info_read(m, &msgs_in_queue);
                        if (!msg)
                        if (msg->data.result != CURLE_OK)
                                printf("curl error: %d: %s\n",
                        curl_multi_remove_handle(m, msg->easy_handle);
        return 0;

In NetBSD I change network configuration with the following commands:

# ifconfig wm0
# route delete default
# route add default

In Linux Mint I use the following commands:

# ifconfig enp1s0 netmask up
# ip route add default via dev enp1s0 onlink

Here are curl version information for both NetBSD and Linux:

NetBSD 9.2$ curl -v
curl 7.79.0 (x86_64--netbsd) libcurl/7.79.0 OpenSSL/1.1.1k zlib/1.2.10 libidn2/2.3.2 nghttp2/1.44.0
Release-Date: 2021-09-15
Protocols: dict file ftp ftps gopher gophers http https imap imaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB SPNEGO SSL TLS-SRP UnixSockets

Linux Mint 20.2$ curl -V
curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3
Release-Date: 2020-01-08
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets
Received on 2022-01-26