我正在尝试查找 PHP 中的 cURL 调用问题.它在我们的测试环境中运行良好,但在我们的生产环境中却不行.当我尝试执行 cURL 函数时,它只是挂起并且永远不会响应.我试过从命令行建立一个 cURL 连接,同样的事情发生了.
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 function, it just hangs and never ever responds. I have tried making a cURL connection from the command line and the same thing happens.
我想知道 cURL 是否记录了某处正在发生的事情,因为我无法弄清楚在命令搅动和搅动期间发生了什么.有谁知道是否有记录那里发生的事情的日志?
I'm wondering if cURL logs what is happening somewhere, because I can't figure out what is happening during the time the command is churning and churning. Does anyone know if there is a log that tracks what is happening there?
我认为这是连接问题,但我们的 IT 人员坚持认为我应该能够毫无问题地访问它.有任何想法吗?我正在运行 CentOS 和 PHP 5.1.
I think it is connectivity issues, but our IT guy insists I should be able to access it without a problem. Any ideas? I'm running CentOS and PHP 5.1.
更新:使用详细模式时,我收到错误 28Connect() Timed Out".我尝试将超时时间延长到 100 秒,并将 max-redirs 限制为 5,没有变化.我尝试ping盒子,也有超时.因此,我将把它提交给 IT 部门,看看他们是否会再看一遍.感谢所有的帮助,希望我能在半小时后回来告诉他们这是他们的问题.
Updates: Using verbose mode, I've gotten an error 28 "Connect() Timed Out". I tried extending the timeout to 100 seconds, and limiting the max-redirs to 5, no change. I tried pinging the box, and also got a timeout. So I'm going to present this back to IT and see if they will look at it again. Thanks for all the help, hopefully I'll be back in a half-hour with news that it was their problem.
更新 2: 原来我的机器正在使用外部 IP 地址解析服务器名称.当 IT 给我内部 IP 地址并在 cURL 调用中替换它时,一切正常.感谢大家的帮助.
Update 2: Turns out my box was resolving the server name with the external IP address. When IT gave me the internal IP address and I replaced it in the cURL call, everything worked great. Thanks for all the help everybody.
在你的 php 中,你可以设置 CURLOPT_VERBOSE 变量:
In your php, you can set the CURLOPT_VERBOSE variable:
curl_setopt($curl, CURLOPT_VERBOSE, TRUE);
然后记录到 STDERR,或使用 CURLOPT_STDERR
指定的文件(接受文件指针):
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
向命令行报告更多信息--trace <file>
或 --trace-ascii <file>
跟踪到文件--verbose
to report more info to the command line--trace <file>
or --trace-ascii <file>
to trace to a file您可以使用 --trace-time
将时间戳添加到详细/文件输出
You can use --trace-time
to prepend time stamps to verbose/file outputs
这篇关于如何找出 cURL 挂起且无响应的原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!