我怎么知道旋度为什么是挂着的?

时间:2022-07-16 03:59:05

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.

我正在用PHP中的cURL调用跟踪一个问题。它在我们的测试环境中工作得很好,但是在我们的生产环境中却不行。当我尝试执行cURL函数时,它只是挂起,从来没有响应。我尝试从命令行创建一个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?

我想知道cURL是否记录了某个地方正在发生的事情,因为我不知道在命令被搅动和搅动期间发生了什么。有人知道是否有一个日志记录了那里发生的事情吗?

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.

我认为这是连接性的问题,但我们的it人员坚持认为我应该能够毫无问题地访问它。什么好主意吗?运行CentOS和PHP 5.1。

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.

更新:使用详细模式,我得到一个错误28“Connect()超时”。我尝试将超时延长到100秒,并将max-redirs限制为5,没有变化。我试着打开盒子,也得到了一个暂停。我将把这个展示给它看看他们是否会再看一遍。谢谢大家的帮助,希望我能在半小时后回来告诉大家这是他们的问题。

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.

更新2:原来我的方框用外部IP地址解析服务器名。当它给我内部IP地址,我在cURL调用中替换它时,一切都很好。谢谢大家的帮助。

4 个解决方案

#1


16  

In your php, you can set the CURLOPT_VERBOSE variable:

在php中,可以设置CURLOPT_VERBOSE变量:

curl_setopt($curl, CURLOPT_VERBOSE, TRUE);

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

然后记录到STDERR,或者使用CURLOPT_STDERR指定的文件(它接受一个文件指针):

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
  • ——跟踪 或——trace-ascii 到文件的跟踪

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

您可以使用-trace-time来将时间戳前置到详细/文件输出

#2


0  

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

您还可以使用curl_getinfo()获取关于特定传输的信息。

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

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

#3


0  

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.

你试过设置CURLOPT_MAXREDIRS吗?我发现,对于一些普通浏览器用户看不到的网站,有时会有一个“无限”重定向循环。

#4


-1  

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

如果可能的话,在用户PHP运行时(可能是Apache所运行的)尝试sudo ing。

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.

curl问题可能有各种原因需要用户输入,例如存储在根用户的受信任证书缓存中的不受信任证书,而不是PHP证书。在这种情况下,命令将等待从未发生的输入。

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

更新:这只适用于使用exec外部运行curl的情况——可能不适用。

#1


16  

In your php, you can set the CURLOPT_VERBOSE variable:

在php中,可以设置CURLOPT_VERBOSE变量:

curl_setopt($curl, CURLOPT_VERBOSE, TRUE);

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

然后记录到STDERR,或者使用CURLOPT_STDERR指定的文件(它接受一个文件指针):

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
  • ——跟踪 或——trace-ascii 到文件的跟踪

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

您可以使用-trace-time来将时间戳前置到详细/文件输出

#2


0  

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

您还可以使用curl_getinfo()获取关于特定传输的信息。

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

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

#3


0  

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.

你试过设置CURLOPT_MAXREDIRS吗?我发现,对于一些普通浏览器用户看不到的网站,有时会有一个“无限”重定向循环。

#4


-1  

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

如果可能的话,在用户PHP运行时(可能是Apache所运行的)尝试sudo ing。

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.

curl问题可能有各种原因需要用户输入,例如存储在根用户的受信任证书缓存中的不受信任证书,而不是PHP证书。在这种情况下,命令将等待从未发生的输入。

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

更新:这只适用于使用exec外部运行curl的情况——可能不适用。