How can I figure out why cURL is hanging and unresponsive?

后端 未结 4 833
滥情空心
滥情空心 2021-01-04 00:32

I am trying to track down an issue with a cURL call in PHP. It works fine in our test environment, but not in our production environment. When I try to execute the cURL fu

相关标签:
4条回答
  • 2021-01-04 01:13

    If at all possible, try sudo ing as the user PHP runs under (possibly the one Apache runs under).

    The curl problem could have various reasons that require a user input, for example an untrusted certificate that is stored in the trusted certificates cache of the root user, but not the PHP one. In that case, the command would be waiting for an input that never happens.

    Update: This applies only if you run curl externally using exec - maybe it doesn't apply.

    0 讨论(0)
  • 2021-01-04 01:16

    You can also use curl_getinfo() to get information about your specific transfer.

    http://in.php.net/manual/en/function.curl-getinfo.php

    0 讨论(0)
  • 2021-01-04 01:33

    In your php, you can set the CURLOPT_VERBOSE variable:

    curl_setopt($curl, CURLOPT_VERBOSE, TRUE);
    

    This then logs to STDERR, or to the file specified using CURLOPT_STDERR (which takes a file pointer):

    curl_setopt($curl, CURLOPT_STDERR, $fp);
    

    From the command line, you can use the following switches:

    • --verbose to report more info to the command line
    • --trace <file> or --trace-ascii <file> to trace to a file

    You can use --trace-time to prepend time stamps to verbose/file outputs

    0 讨论(0)
  • 2021-01-04 01:36

    Have you tried setting CURLOPT_MAXREDIRS? I've found that sometimes there will be an 'infinite' redirect loop for some websites that a normal browser user doesn't see.

    0 讨论(0)
提交回复
热议问题