0

We run a very busy web site, with php 5.6 on Debian VM, running a curl with this configuration:

$defaults = array(
            CURLOPT_HEADER => 0,
            CURLOPT_URL => $url,
            CURLOPT_FRESH_CONNECT => 1,
            CURLOPT_RETURNTRANSFER => 1,
            CURLOPT_FORBID_REUSE => 1,
            CURLOPT_CONNECTTIMEOUT => 0.5,
            CURLOPT_TIMEOUT => 2
        );

We measure all the time the real duration, sometime we see "timeout" error (which is good), but sometime we measure a duration of more than 2 secondes ! (5 secondes).

I am wondering why curl is not respecting the timeout:

  • Is it another option to configure timeout?
  • very busy VM can cause this (I think about file-descriptors or i-nodes), curl could wait for this
  • This is very impossible, and answer is somewhere else!
Thomas Decaux
  • 21,738
  • 2
  • 113
  • 124
  • How do You measure the "real" duration? – Roman Hocke Jan 24 '19 at 13:06
  • I took microtime before , and after, and save difference into elasticsearch, then I use Kibana to see. – Thomas Decaux Jan 24 '19 at 13:08
  • It could be just another magical wonder of PHP where settings are configured, then simply ignored. https://stackoverflow.com/questions/1856473/why-would-curl-ignore-curlopt-timeout-ms-but-honor-curlopt-timeout – Dimi Jan 24 '19 at 13:53

0 Answers0