Bisher konnte ich nichts wirklich finden, aber stimmt es, dass curl läuft überhaupt nicht ab?
[email protected]:~# curl http://localhost/testdir/image.jpg
Ich frage, weil ich jede Anfrage nach Bildern in testdir umleite zu einem separaten Apache-Modul, das diese Bilder im laufenden Betrieb generiert. Es kann bis zu 15 Minuten dauern, bis das Bild tatsächlich fertig ist und an den anfordernden Kunden geliefert wird.
Wird curl Immer warten (oder ist es konfigurationsabhängig) oder gibt es eine Art Timeout?
Akzeptierte Antwort:
Ja.
Timeout-Parameter
curl hat zwei Optionen:--connect-timeout und --max-time .
Zitat aus der Manpage:
--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.
und:
-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.
Standards
Hier (unter Debian) stoppt es den Verbindungsversuch nach 2 Minuten, unabhängig von der mit --connect-timeout angegebenen Zeit und obwohl der Standardwert für das Verbindungszeitlimit 5 Minuten zu sein scheint gemäß dem DEFAULT_CONNECT_TIMEOUT Makro in lib/connect.h.
Ein Standardwert für --max-time scheint nicht zu existieren, wodurch curl entsteht Warten Sie ewig auf eine Antwort, wenn die erste Verbindung erfolgreich war.
Was verwenden?
Sie interessieren sich wahrscheinlich für die letztere Option, --max-time . Setzen Sie ihn für Ihren Fall auf 900 (15 Minuten).
Angabe der Option --connect-timeout zu etwas wie 60 (eine Minute) könnte auch eine gute Idee sein. Andernfalls curl wird immer wieder versuchen, eine Verbindung herzustellen, anscheinend mit einem Backoff-Algorithmus.