GNU/Linux >> Linux の 問題 >  >> Linux

Curlにはタイムアウトがありますか?

今のところ実際には何も見つかりませんでしたが、curlは本当です 本当にタイムアウトしませんか?

 [email protected]:~# curl http://localhost/testdir/image.jpg

testdir内の画像のリクエストをリダイレクトしているので、質問しています それらの画像をその場で生成する別のApacheモジュールに。写真が実際に準備され、要求元のクライアントに配信されるまでに最大15分かかる場合があります。

curl 常に待機しますか(または構成によって異なりますか)、それとも何らかのタイムアウトがありますか?

承認された回答:

はい。

タイムアウトパラメータ

curl 2つのオプションがあります:--connect-timeout および--max-time

マンページからの引用:

--connect-timeout <seconds>
    Maximum  time  in  seconds  that you allow the connection to the
    server to take.  This only limits  the  connection  phase,  once
    curl has connected this option is of no more use.  Since 7.32.0,
    this option accepts decimal values, but the actual timeout  will
    decrease in accuracy as the specified timeout increases in deci‐
    mal precision. See also the -m, --max-time option.

    If this option is used several times, the last one will be used.

および:

-m, --max-time <seconds>
    Maximum  time  in  seconds that you allow the whole operation to
    take.  This is useful for preventing your batch jobs from  hang‐
    ing  for  hours due to slow networks or links going down.  Since
    7.32.0, this option accepts decimal values, but the actual time‐
    out will decrease in accuracy as the specified timeout increases
    in decimal precision.  See also the --connect-timeout option.

    If this option is used several times, the last one will be used.

デフォルト

ここ(Debianの場合)では、--connect-timeoutで指定された時間に関係なく、2分後に接続の試行が停止します。 デフォルトの接続タイムアウト値は5分のようですが DEFAULT_CONNECT_TIMEOUTによると lib/connect.hのマクロ。

--max-timeのデフォルト値 存在しないようで、curl 最初の接続が成功した場合は、応答を永久に待ちます。

何を使用しますか?

おそらく後者のオプションである--max-timeに興味があるでしょう。 。あなたの場合は900に設定してください (15分)。

関連:「du-sh*」と「du-sh./*」の違いは?

オプション--connect-timeoutを指定する 60のようなものに (1分)も良い考えかもしれません。それ以外の場合はcurl どうやら何らかのバックオフアルゴリズムを使用して、何度も接続を試みます。


Linux
  1. プログラムは、カラー出力を使用するかどうかをどのように決定しますか?

  2. Linux – Linuxの「nointremap」オプションは何をしますか?

  3. 「/」に「..」エントリがあるのはなぜですか?

  1. Linux カーネルにはメイン機能がありますか?

  2. Curl show Content-Type のみ

  3. パイプは一時ファイルを書き込む必要がありますか?

  1. /etc/fstab の sw オプションはどういう意味ですか?

  2. Linuxにはどのようなプロセスキラーがありますか?

  3. プロセスは所有者を持つことができますか?どういう意味ですか?