doujia1939 2015-07-27 08:49
浏览 66
已采纳

file_get_contents失败,带有空异常

I have a strange behaviour of file_get_contents. We are behind a proxy, so I needed to set the context of file_get_contents. The strange thing is, on my PC it works fine, but on other PC or at other location it won't work, running into the max_execution_time timeout.

if ($requestType == 'GET') {
            $context = [ 
                    'http' => [ 
                            'method' => 'GET',
                            'header' => "Authorization: " . dbQueryHelper::getApiKey () . "
" . "Content-Type: application/x-www-form-urlencoded
",
                            'proxy' => getenv ( 'PROXY' ),
                            'request_fulluri' => true 
                    ],
                    'ssl' => array(
                        'SNI_enabled' => false, // Disable SNI for https over http proxies
                        'proxy' => getenv('PROXY'),
                        'request_fulluri' => true,
                        "verify_peer"=>false,
                        "verify_peer_name"=>false,
                    )
            ];
        }
$context = stream_context_create ( $context );

$dataraw = [
        'email' => getenv('DEVMAIL'),
        'userEmail' => $user->getNickname(),
        'production' => getenv('PROD')
];
$data = http_build_query ( $dataraw );
$context = dbQueryHelper::getContext ( 'GET' ); // this gets the context from above
$result = file_get_contents ( getenv('RESTAPIURL') . '/getPernrByEmail?' . $data, false, $context );
$result = json_decode ( $result, true );

I also get no error message on the other PCs, only

Warning: file_get_contents(...): in C:\trainingplan\lib\common.php on line 79

I think the strange thing is that the warning contains no error... We don't think it could be the proxy because I use the same proxy everywhere and can also use different proxies - same behaviour, on my PC it works, on others not. I also tried with disabling Firewall and UAC and other security services on other PCs, doesn't work as well... We have no clue what could be the root cause.

Do you have any idea for me?

  • 写回答

1条回答 默认 最新

  • dorbmd1177 2015-07-28 09:02
    关注

    We finally found the solution. It was not network related. It is a bug with PHP 5.5 contained in the Google App Engine Launcher Installer. When specified

    runtime: php55
    

    in the app.yaml, the above mentioned symptoms occur. When we change the runtime to

    runtime: php
    

    it works fine with proxy and everything. This could be kind of problematic, as Google already deprecated usage of "runtime: php" and you can only upload applications with "runtime: php55" to the App Engine servers. But I think a reasonable workaround would be to develop locally with "runtime: php" and change it to "runtime: php55" only for the upload - but I have no idea if that could have other impacts...

    Another cause we experienced yesterday was IPv6. In App Engine Launcher v1.9.23 it helps to disabled IPv6 completely in the entwork settings of your PC. After a restart the php-cgi.exe of GAE Launcher connects correctly through the IPv4 proxy.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示