2016-07-25 90 views
1

我有一個PHP的Android推送通知腳本。當我運行該腳本時,我在瀏覽器中收到以下響應「504 Gateway Time-out nginx」。 在我在通用日誌概述我碰到下面的錯誤服務器:Nginx提供的PHP-FPM:504網關超時 - nginx

Error: 504, Message: GET /gcm_test.php HTTP/1.1, Source: nginx SSL access

在我的proxy_error_log我碰到下面的錯誤服務器:

2016/07/25 08:18:19 [error] 23882#0: *4375 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 12.34.567.891, server: website.com, request: "GET /gcm_test.php HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/website.com/php-fpm.sock", host: "www.website.com"

Android的推送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);」用「echo」腳本結尾「;」我沒有得到任何錯誤,結果是「腳本結束」。 所以它看起來像問題是在「$結果= curl_exec($ ch);」

我也試過以下,PLESK nginx 504 error: Gateway Timeout沒有運氣。

在我的服務器我跑PHP7.0.4由nginx的

有人什麼想法擔任FPM應用程序? 謝謝!

回答

1

看起來你需要在你的nginx配置中增加fastcgi_read_timeout