推送通知发送成功,但该设备没有收到(偶尔) [英] Push notification is successfully sent, but the device does not receive (occasionally)

查看:142
本文介绍了推送通知发送成功,但该设备没有收到(偶尔)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直有在那里有些设备将不会收到一个推送通知,从昨天开始出现问题。
证书/ devicetoken似乎是正确的,
因为设备使用成功地接收到推送通知直到昨天。

I have been having a problem where some devices will not receive a push notification, since yesterday. The certificate / devicetoken seem to be correct, since the device used to successfully receive push notifications until yesterday.

在服务器端,没有错误或连接拒绝,
和推送通知,似乎每一次发送成功。

On the server-side, there are no errors or connection refusals, and the push notification seems to be successfully sent every time.

但尽管如此,也有许多场合的设备无法正常收到推送。

But still, there are many occasions where the device does not correctly receive the push.

周边的一些信息:


  • 我在生产环境中这样做。

  • 没有错误/在服务器端连接拒绝

  • 我发送完全相同JSON每次。

  • 我们的设备有2个是没有收到推送通知,因为在所有昨天

  • 我们的设备的
  • 1接收以较低的成功率(约70%),比昨天
  • 推送通知
  • 1〜2我们的设备仍收到推送通知的成功即使是现在。

  • 所有上述设备能够在生产环境中正常收到推送通知,直到昨天。

<强>有用于当推是成功的,并且当设备没有收到它在服务器端的结果没有差别...
因此,这是几乎不可能找出问题所在。

这是服务器端的PHP code我使用的:

This is the server-side PHP code I am using:

        $ctx = stream_context_create();
        stream_context_set_option($ctx, 'ssl', 'local_cert', $this->apnsData[$development]['certificate']);
        $fp = stream_socket_client($this->apnsData[$development]['ssl'], $error, $errorString, 100, (STREAM_CLIENT_C ONNECT|STREAM_CLIENT_PERSISTENT), $ctx);

        if(!$fp){
                $this->_pushFailed($pid);
                $this->_triggerError("Failed to connect to APNS: {$error} {$errorString}.");
        }
        else {
                $msg = chr(0).pack("n",32).pack('H*',$token).pack("n",strlen($message)).$message;
                $fwrite = fwrite($fp, $msg);
                if(!$fwrite) {
                        error_log("[APNS] push failed...");
                        $this->_pushFailed($pid);
                        $this->_triggerError("Failed writing to stream.", E_USER_ERROR);
                }
                else {
                        error_log("[APNS] push successful! ::: $token -> $message ($fwrite bytes)");
                }
        }
        fclose($fp);

日志告诉我,推成功(切割出对隐私的令牌):

The log tells me that the push was successful (Cutting out the token for privacy) :

[Wed Dec 12 11:42:00 2012] [error] [client 10.161.6.177] [APNS] push successful! ::: aa4f******44 -> {"aps":{"alert":{"body":"\\u300casdfasdf\\u300d","action-loc-key":"OK"},"badge":4,"sound":"chime"}} (134 bytes)

有什么办法,我可以得到这个问题的帮助?
或者有没有谁是有同样的问题?任何人

Is there any way I can get help on this problem? Or is there anybody who is having the same problem??

请帮帮忙!我得到这个从一些用户的抱怨......

Please help! I am getting complaints from some users on this....

推荐答案

由我自己解决了这一点,所以我将发布一个答案。

Solved this by myself, so I'll be posting an answer.

我收到意见,建议不要开启和关闭为每一个消息插座,如苹果公司的官方文件指出:

I've received advice that opening and closing the socket for every single message is not recommended, as noted in Apple's official documents:

你也应该保持与跨越多个通知的APN连接。APN的可以考虑迅速和反复建立和拆除的拒绝服务攻击的连接。一旦错误的APN逢发生错误的连接。

"You should also retain connections with APNs across multiple notifications. APNs may consider connections that are rapidly and repeatedly established and torn down as a denial-of-service attack. Upon error, APNs closes the connection on which the error occurred."

我固定我的体系结构,以便连接整个保留多个电话APNS,现在它正在没有任何问题。
我创建了一个基于APNS-PHP的一个排队系统( https://开头code .google.com / p / APNS的PHP / )。

I fixed my architecture so that the connection is retained throughout multiple APNS calls, and now it is working without any problem. I created a queueing system based on apns-php (https://code.google.com/p/apns-php/).

下面是我的code,任何人谁需要它:

Here is my code, for anyone who needs it:

https://github.com/ashiina/APNS-QueueServer

这篇关于推送通知发送成功,但该设备没有收到(偶尔)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆