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
changes.

I just enabled CURLOPT_VERBOSE and I see things like this:

* Found bundle for host example.com: 0x7a8c9fd2a210 [can multiplex]
* Re-using existing connection! (#0) with host example.com
* Connected to example.com (93.184.216.34) port 443 (#0)
* Using Stream ID: 3 (easy handle 0x7a8c9fcde800)
> GET / HTTP/2
Host: example.com
accept: */*
* Operation timed out after 4999 milliseconds with 0 bytes received
* stopped the pause stream!
* Connection #0 to host example.com 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 https://example.com 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
interface.

#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, "https://example.com";);
                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)
                                continue;
                        if (msg->data.result != CURLE_OK)
                                printf("curl error: %d: %s\n",
                                        msg->data.result,
                                        curl_easy_strerror(msg->data.result));
                        curl_multi_remove_handle(m, msg->easy_handle);
                        curl_easy_cleanup(msg->easy_handle);
                }
                sleep(5);
        }
        curl_multi_cleanup(m);
        return 0;
}

In NetBSD I change network configuration with the following commands:

# ifconfig wm0 192.168.0.200
# route delete default
# route add default 192.168.0.1

In Linux Mint I use the following commands:

# ifconfig enp1s0 192.168.0.200 netmask 255.255.255.0 up
# ip route add default via 192.168.0.1 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
-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html

Reply via email to