GAE PHP超时设置


GAE PHP timeout setting

我在GAE上的PHP应用程序显示错误日志:

PHP警告:file_get_contents(http://cx.xaa.cc/checkgs.asp):未能打开流:请求截止日期超过/base/data/home/apps/s~turn-get-into-post/1.367938585442433732/turn-get-into-post. PHP第94行

任何想法?

您看到此错误是因为http://cx.xaa.cc/checkgs.asp服务器响应时间过长。默认情况下,URLfetch(当使用http或https URL时,在GAE的PHP中为file_get_contents()提供动力的应用引擎服务)的默认超时时间为5秒。

通常,您可以通过在配置数组中指定timeout将其扩展到60秒,如下所示:

$data = http_build_query($data); 
$context = 
   array("http"=> 
      array( 
         "method" => "POST", 
         "content" => $data, 
         "timeout" => 60 
   ) 
); 
$context = stream_context_create($context); 
$result = file_get_contents($url, false, $context); 

但是在短期内要注意这个bug。https://code.google.com/p/googleappengine/issues/detail?id=9460