APNS + PHP“stream_socket_client():启用加密失败"; [英] APNS + PHP "stream_socket_client(): Failed to enable crypto"

查看:18
本文介绍了APNS + PHP“stream_socket_client():启用加密失败";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将 APNS 与 PHP 结合使用时遇到问题并收到以下消息:

I'm having trouble with using APNS with PHP and getting the following message:

stream_socket_client(): Failed to enable crypto

这个问题只是偶尔发生,其他时候它实际上会发送推送.

The problem only happens sometimes, and other times it would actually send the push.

由于我有 10 次迭代循环的测试脚本,我有时会得到这个:

Since I have the test script on a loop of 10 iterations, I would sometimes get this:

stream_socket_client(): SSL: Connection reset by peer

我正在使用沙盒服务器进行测试 tls://gateway.sandbox.push.apple.com:2195

I'm testing using the sandbox server tls://gateway.sandbox.push.apple.com:2195

这是我尝试过的:

  • 我尝试重新颁发 PEM 及其所有证书.
  • 我使用了请求协议 sslv3://tls://.
  • 我玩弄了密码短语(顺便说一句,没有密码短语的推送工作)
  • 我尝试在 stackoverflow 中搜索解决方案,但没有任何效果.
  • 检查pem文件权限644
  • 检查 pem 父目录权限 755

我在 Google 和 SO 上找到的所有解决方案似乎都是人们在推动问题时遇到的问题.

It seems that all the solutions I found on Google and SO are people having problem pushing altogether.

我觉得该服务可能是限速的?因为我们等了一段时间(大约 15 分钟)然后再次尝试,并且能够成功推送大约 100 条消息,直到我再次开始收到该消息.

I feel like the service is rate limited maybe? Because we waited a while (around 15 minutes) and then tried it again, and was able to successfully push around 100 messages until I started getting that message again.

推荐答案

沙盒推送服务有速率限制.我自己在测试时遇到过这种情况,但在使用生产 API 时从未遇到过任何此类限制.

The sandbox push service is rate limited. I have experienced this myself when testing but have never encountered any such limit using the production API.

您可能还会遇到他们的其他保护措施.

You might also be hitting their other protections.

您是打开连接、发送消息、关闭连接,然后循环再做一遍吗?

Are you opening a connection, sending a message, closing connection and then looping and doing it all over again?

这会让你的通知被删除.Apple 希望您使用同一个连接发送多条推送通知,而不是每次都发送一条新通知.

That will get your notifications dropped. Apple wants you to send several push notifications using the same connection, not a new one each time.

管理连接的最佳做法

您可以建立多个连接到同一个网关或多个网关实例.如果您需要发送大量远程通知,通过连接将它们分散到多个不同的网关.与使用单连接:它可以让您更快地发送远程通知,并且可以让 APN 更快地交付它们.

You may establish multiple connections to the same gateway or to multiple gateway instances. If you need to send a large number of remote notifications, spread them out over connections to several different gateways. This improves performance compared to using a single connection: it lets you send the remote notifications faster, and it lets APNs deliver them faster.

在多个通知中保持与 APNs 的连接;不要反复打开和关闭连接.APNs 治疗快速连接和断开连接作为拒绝服务攻击.您应该保持连接打开,除非您知道它会空闲一段时间延长时间——例如,如果您只向您的用户每天使用一次新连接是可以的.

Keep your connections with APNs open across multiple notifications; don’t repeatedly open and close connections. APNs treats rapid connection and disconnection as a denial-of-service attack. You should leave a connection open unless you know it will be idle for an extended period of time—for example, if you only send notifications to your users once a day it is ok to use a new connection each day.

来自 Apple Docs @ https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html

From Apple Docs @ https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html

这篇关于APNS + PHP“stream_socket_client():启用加密失败";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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