Movatterモバイル変換


[0]ホーム

URL:


everything curl

    Keep alive

    TCP connections can be totally without traffic in either direction when theyare not used. A totally idle connection can therefore not be clearly separatedfrom a connection that has gone completely stale because of network or serverissues.

    At the same time, lots of network equipment such as firewalls or NATs arekeeping track of TCP connections these days, so that they can translateaddresses, block "wrong" incoming packets, etc. These devices often countcompletely idle connections as dead after N minutes, where N varies betweendevice to device but at times is as short as 10 minutes or even less.

    One way to help avoid a really slow connection (or an idle one) gettingtreated as dead and wrongly killed, is to make sure TCP keep alive isused. TCP keepalive is a feature in the TCP protocol that makes it send "pingframes" back and forth when it would otherwise be totally idle. It helps idleconnections to detect breakage even when no traffic is moving over it, andhelps intermediate systems not consider the connection dead.

    curl uses TCP keepalive by default for the reasons mentioned here. There mightbe times when you want todisable keepalive or you may want to change theinterval between the TCP "pings" (curl defaults to 60 seconds). You can switchoff keepalive with:

    curl --no-keepalive https://example.com/

    or change the interval to 5 minutes (300 seconds) with:

    curl --keepalive-time 300 https://example.com/

    Starting in curl 8.9.0 you can set the number of keepalive probes curl sendsbut not getting a response to before it gives up, with--keepalive-cnt. Likethis:

    curl --keepalive-cnt 3 https://example.com

    [8]ページ先頭

    ©2009-2025 Movatter.jp