PHPはAmazonのプッシュ通知サービス経由でプッシュ通知リクエストをApple Push Notificationサービスに送信するGoDaddyサーバーに座っています。PHPルーチンがAWS経由でAPNSプッシュ通知を送信すると、内部サーバーエラーが500件発生します
20人以上のユーザーにプッシュ通知を送信すると、通知の送信を開始したユーザーがGoDaddy Internal Server 500エラーを取得します。
障害を引き起こした特定のDeviceTokensをトレースし、同じルーチンを使用してこれらの特定のDeviceTokensに通知を送信しています。そのため、問題は断続的で特定のDeviceTokenとは無関係です。
私はの不審なよ: (1)デバイスを20 +するために送信するとき、私はAWSExceptions をキャッチするために更新した例外ハンドラは、(2)問題が発生したので、おそらくそれは、タイムアウトの問題(私が設定しているんですPHPページでタイムアウト= 0)ここで
はコードです - 本当に望んで誰かが助けることができる:
static public function send_push_notification($message, $token, $badge = 1)
{
$sns = SnsClient::factory(array(
'credentials' => array(
'key' => '<redacted>',
'secret' => '<redacted>'
),
'region' => 'us-west-1',
'version' => '2010-03-31'
));
$ios_arn = "arn:aws:sns:us-west-1:<redacted>";
$ios_endpoints = $sns->listEndpointsByPlatformApplication(array(
'PlatformApplicationArn' => $ios_arn
));
$arn = "";
foreach ($ios_endpoints['Endpoints'] as $endpoint) {
if ($token == $endpoint['Attributes']['Token']) {
$arn = $endpoint['EndpointArn'];
}
}
if ($arn == "") {
$arn = SNSPushNotifications::register_device($token);
}
try {
$contents = array();
$contents['badge'] = $badge;
$contents['alert'] = addslashes($message);
$contents['sound'] = "default";
$push = array(
"aps" => $contents
);
$push_json = json_encode($push);
$json = json_encode(array(
'APNS' => $push_json
));
$sns->publish(array(
'MessageStructure' => 'json',
'Message' => $json,
'TargetArn' => $arn
));
}
catch (AWSException $e) {
$mess=$e->getAwsRequestId() . "\n";
$mess.=$e->getAwsErrorType() . "\n";
$mess.=$e->getAwsErrorCode() . "\n";
$m="Push notification sent to ".get_token_user($token)."($token) failed: " . $endpointArn . "<br/><strong>Error:</strong> " . $mess . "<br/>";
$headers = "From: <redacted>\r\n";
$headers .= "Reply-To: <redacted>\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail("<redacted>","Push Notification Failure",$m, $headers);
if ($mess=="Endpoint is disabled") delete_token($token);
}
}
ありがとうございます - 静的を正しい位置に更新しました。 私はGoDaddy Linux共有ホスティングを使用しています。バックトレースエラーログにどこからアクセスできますか? – rihallix
AWSExceptionにはどのようなメッセージが表示されますか? –