CURLOPT_UP...NTERVAL_MS(3)
π CURLOPT_UPKEEP_INTERVAL_MS β connection upkeep interval β¨
okay so real talk, this one lives in the libcurl manual (yes, the Library Functions Manual, we're fancy), and it's genuinely one of the more underrated little settings. bestie, it's giving "connective tissue" and honestly? obsessed.
πΈ NAME πΈ
CURLOPT_UPKEEP_INTERVAL_MS β the connection upkeep interval, aka how often your connection gets a lil "hey bestie u still there?" π
β¨ SYNOPSIS β¨
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_UPKEEP_INTERVAL_MS,
long upkeep_interval_ms);
π¦ DESCRIPTION π¦
so some protocols have these whole "connection upkeep" mechanisms, right? it's lowkey iconic β they send a bit of traffic across the connections you've already got open, purely to keep them alive. and likeβ¦ why does that matter? because some overzealous firewall out there will absolutely close your connection for being too quiet. no cap, firewalls are the main character of their own drama. π₯
the catch, and this is important: the user has to explicitly call curl_easy_upkeep(3) to actually do the upkeep work. it does not happen magically on its own. you have to show up and ask. π
and currently β as in right now, today β the only protocol with a connection upkeep mechanism is HTTP/2. here's the vibe: when the connection upkeep interval gets exceeded and curl_easy_upkeep(3) is called, an HTTP/2 PING frame gets sent on the connection. that's it, that's the whole mechanism. π
π DEFAULT π
CURL_UPKEEP_INTERVAL_DEFAULT β which is currently defined as 60000L, which is 60 seconds. cute, round, sensible. slay.
π PROTOCOLS π
this functionality affects all supported protocols. all of them. every single one. periodt. π
π EXAMPLE π
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
/* Make a connection to an HTTP/2 server. */
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Set the interval to 30000ms / 30s */
curl_easy_setopt(curl, CURLOPT_UPKEEP_INTERVAL_MS, 30000L);
curl_easy_perform(curl);
/* Perform more work here. */
/* While the connection is being held open, curl_easy_upkeep() can be
called. If curl_easy_upkeep() is called and the time since the last
upkeep exceeds the interval, then an HTTP/2 PING is sent. */
curl_easy_upkeep(curl);
/* Perform more work here. */
/* always cleanup */
curl_easy_cleanup(curl);
}
}
β AVAILABILITY β
added in curl 7.62.0. she's not ancient, she's not brand new β she's just right. π«Ά
π RETURN VALUE π
curl_easy_setopt(3) returns a CURLcode that tells you whether it slayed or flopped.
CURLE_OK (0) means everything was OK. anything non-zero means an error happened β go check libcurl-errors(3) and it'll explain the whole situation. π
π SEE ALSO π
CURLOPT_TCP_KEEPALIVE(3)β the other keep-alive bestie, go say hi π
and that's the whole page, bestie!! this fine piece of documentation came to you straight from libcurl, dated 2026-10-12, and it's CURLOPT_UPKEEP_INTERVAL_MS(3) all day every day. go keep those connections alive, ily, bye π§β¨
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms