curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support. 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 Daniel himself.

Curl timing confusion

From: Michael Newman via curl-users <curl-users_at_lists.haxx.se>
Date: Thu, 22 Jan 2026 13:23:28 +0700

I’m trying to figure out what I’ve done wrong with respect to limiting how much time curl takes to perform a single file upload.

Here’s the code I’m using.

for i in {1..3}
 do
        echo $'\n'"`date`" Upload Attempt "$i" - $(hostname) >> "$log"

        curl -s -S -v -u mgnewman: \
        --connect-timeout 30 \
        --max-time 30 \
        --pubkey ~/.ssh/id_rsa.pub \
        -T $file $host &>> $log

        err=$?

        echo $'\n'"`date`" Upload Ended "$err" - $(hostname) >> "$log"

        touch /home/pi/webcam/webcam.webp

        if [ $err -eq 0 ] ; then
                break
        fi
done

Note that I’m using a “do loop” rather than curl’s retry option because between each iteration I want to touch an existing image file to prevent watchdog from rebooting the machine which it does if the image is not refreshed in ten minutes.

I’m trying to limit each iteration of curl to 30 seconds, but that doesn’t seem to work. Here’s a fragment of my log file:

Wed Jan 21 23:37:24 +07 2026 Upload Attempt 3 - raspcondo

* Trying 192.nnn.nnn.101...
* TCP_NODELAY set
* Connected to xxxxxxx.com (192.nnn.nnn.101) port 22 (#0)
* SSH MD5 fingerprint: 4b17cad500a405c850e118c1deec0f96
* SSH host check: 0, key: AAAAB3NzaC1yc2EAAAADAQABAAABAQCzCyhhdYNOn5Zgib7qhPKev$
* SSH authentication methods available: publickey,password,keyboard-interactive
* Using SSH public key file '/home/pi/.ssh/id_rsa.pub'
* Using SSH private key file '/home/pi/.ssh/id_rsa'
* Initialized SSH public key authentication
* Authentication complete
* Operation timed out after 30000 milliseconds with 0 out of 0 bytes received
* Closing connection 0
curl: (28) Operation timed out after 30000 milliseconds with 0 out of 0 bytes r$

Wed Jan 21 23:48:09 +07 2026 Upload Ended 28 - raspcondo

My conclusion is that I don’t understand how this works as it seems that around ten minutes elapsed between the time curl started (23:37:24) and the time it failed (23:48:09) with error 28.

Note that I realize the code is rather sloppy, but I’m just a hobbyist and that’s about the best I can do. Sorry.

Mike Newman
Korat, Thailand



-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
Etiquette:   https://curl.se/mail/etiquette.html
  • application/pkcs7-signature attachment: smime.p7s
Received on 2026-01-22