我有一个PHP Android Push通知脚本。当我运行脚本时,在浏览器中收到以下响应“ 504网关超时nginx”。在常规日志概述中的服务器上,出现以下错误:
错误:504,消息:GET /gcm_test.php HTTP / 1.1,来源:nginx SSL访问
在我的服务器上proxy_error_log中,出现以下错误:
2016/07/25 08:18:19 [错误] 23882#0:* 4375上游超时(110:连接超时),同时从上游读取响应头,客户端:12.34.567.891,服务器:website.com,请求: “ GET /gcm_test.php HTTP / 1.1”,上游:“ fastcgi:// unix:///var/www/vhosts/system/website.com/php-fpm.sock”,主机:“ www.website.com ”
Android Push PHP脚本:
<?php
// Replace with the real server API key from Google APIs
$apiKey = "my apikey";
// Replace with the real client registration IDs
$registrationIDs = array("red id1", "reg id2");
// Message to be sent
$message = "Your message e.g. the title of post";
// Set POST variables
$url = 'https://gcm-http.googleapis.com/gcm/send';
$fields = array(
'registration_ids' => $registrationIDs,
'data' => array( "message" => $message ),
);
$headers = array(
'Authorization: key=' . $apiKey,
'Content-Type: application/json'
);
// Open connection
$ch = curl_init();
// Set the URL, number of POST vars, POST data
curl_setopt( $ch, CURLOPT_URL, $url);
curl_setopt( $ch, CURLOPT_POST, true);
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
//curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode( $fields));
// Execute post
$result = curl_exec($ch);
// Close connection
curl_close($ch);
// print the result if you really need to print else neglate this
echo $result;
?>
如果我替换行“ $ result = curl_exec($ ch);” 与“回声”脚本的结尾“;” 我没有收到任何错误,结果是“脚本结束”。因此,问题似乎出在“ $ result = curl_exec($ ch);”行中。
我还尝试了以下PLESK nginx 504错误:没有运气的网关超时。
在服务器上,我正在运行PHP7.0.4作为Nginx提供的FPM应用程序
有人有什么想法吗?谢谢!
看起来您需要增加fastcgi_read_timeout
nginx配置。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句