本文介绍了我如何弄清楚为什么cURL是悬挂和无响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在追踪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 。我试图将超时延长到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是悬挂和无响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 05:54