Skip to content

option CURLOPT_TCP_KEEPALIVE doesn't work with new version #14368

Description

@feelingseas

I did this

I use curl to request to a php web api.
The PHP server will take a long time to answer the request ,like 600 seconds.So,I need to keep alive to wait the reply.
Old version 7.65.3 works well,but new version failed .I tried new two version 8.9.0,8.9.1,complied in win 10 with vs2019.
main code like this:

`//http is the same,this url sleep ,eg,300s ,then reply
curl_easy_setopt(curl, CURLOPT_URL, "https://www.some.com");
curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
//
curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE,60L);
//
curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 30L);
//
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 600L);//600s timeout

CURLcode res = curl_easy_perform(curl);
if(res == CURLE_OK) {
//7.65.3 will come here
} else {
//timeout
//new version will come here 8.9.0,8.9.1
}`

I expected the following

keep alive

curl/libcurl version

version 7.65.3 works
version 8.9.0 or 8.9.1 does'nt work

operating system

win10,with openssl 3.3.1

Activity

  1. feelingseas commented on Aug 3, 2024

    @feelingseas
    Author

    I used wireShark to analyze the net package .The new version really doesn't send the [Tcp keep-alive ack] package.
    So,I use curl with wrong way?Or is something wrong with the new version.
    That's all.

  2. bagder commented on Aug 3, 2024

    @bagder
    Member

    Tell us how you build your libcurl. Or maybe single-step through tcpkeepalive and tell us where it goes wrong?

    tcpkeepalive(struct Curl_easy *data,

  3. feelingseas commented on Aug 4, 2024

    @feelingseas
    Author

    I use cmake-gui to configure,and vs2019 compiled.Like this .
    I really sorry for my bad english.Also ,I can just use libaries ,not good at c/c++ details.Curl includes many net protocals ,It makes me confused.
    I may waste your time ,sorry for that.
    curl-keep-alive

  4. feelingseas commented on Aug 4, 2024

    @feelingseas
    Author

    cmake-gui output info:
    /////////////////////////////////////////
    Using CMake version 3.22.2
    Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19045.
    curl version=[8.9.1]
    Could NOT find LibPSL (missing: LIBPSL_LIBRARY LIBPSL_INCLUDE_DIR)
    Could NOT find LibSSH2 (missing: LIBSSH2_LIBRARY LIBSSH2_INCLUDE_DIR)
    Performing Test HAVE_WIN32_WINNT
    Performing Test HAVE_WIN32_WINNT - Success
    Found _WIN32_WINNT=0x0a00
    Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
    Features: alt-svc AsynchDNS HSTS HTTPS-proxy IPv6 Largefile libz NTLM SSL threadsafe TLS-SRP UnixSockets
    Enabled SSL backends: OpenSSL
    Configuring done

  5. samjessup commented on Aug 19, 2024

    @samjessup
    Contributor

    I built curl on windows 10 with the default cmake options, and the problem is in lib\cf-socket.c KEEPALIVE_FACTOR is set to 1000 so they are being converted to milliseconds, but it is using setsockopt which is expecting seconds. PR here, sorry if any mistakes, first time: #14606

  6. added a commit that references this issue on Aug 20, 2024
    d8cefac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    WindowsWindows-specific

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions