Stream_socket_client 无法连接(连接超时)

发布于 2024-08-11 21:23:05 字数 587 浏览 10 评论 0 原文

我正在使用证书,并且私钥

$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', $certfile);
stream_context_set_option($ctx, 'ssl', 'passphrase', $pass);
$fp = stream_socket_client('ssl://gateway.xyz.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);

在我的本地 XAMPP 服务器中运行,但在外部服务器中不起作用:

警告:stream_socket_client() [function.stream-socket-client]:无法连接到 /home/biranchi/public_html/ 中的 ssl://gateway.sandbox.push.apple.com:2195 (连接超时) Push.php 第 42 行

连接110失败

错误是什么?我需要更改服务器中的某些设置吗?

I am using the certificate, and the private key

$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', $certfile);
stream_context_set_option($ctx, 'ssl', 'passphrase', $pass);
$fp = stream_socket_client('ssl://gateway.xyz.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);

Its running in my local XAMPP Server, but its not working in the external server:

Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Connection timed out) in /home/biranchi/public_html/push.php on line 42

Failed to connect 110

What is the error? Do i need to change some setting in the server?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

苯莒 2024-08-18 21:23:05

我通过在生产服务器上打开端口 2195 解决了该问题。您可以通过以下命令进行验证 $telnet gateway.push.apple.com 2195

-bash-3.2# telnet gateway.push.apple.com 2195

Trying 17.149.38.141...
Connected to gateway.push.apple.com (17.149.38.141).
Escape character is '^]'.
Connection closed by foreign host.

I had fixed the issue by opening the port 2195 on the production server. You can verify by following command $telnet gateway.push.apple.com 2195

-bash-3.2# telnet gateway.push.apple.com 2195

Trying 17.149.38.141...
Connected to gateway.push.apple.com (17.149.38.141).
Escape character is '^]'.
Connection closed by foreign host.
心舞飞扬 2024-08-18 21:23:05

检查您的个人防火墙设置并确保您没有阻止此操作。尝试禁用防火墙。

此外,某些 API 喜欢来自实际域而不是桌面的请求。我没有理由相信苹果是这样工作的,但这也是需要检查的事情。

另请确保 ping gateway.sandbox.push.apple.com 并确保连接良好。

Check your personal firewall settings and make sure you're not blocking this out. Try disabling the firewall.

Also, some APIs like requests to come from an actual domain rather than a desktop. I don't have reason to believe Apple works this way, but that's something to check also.

Also make sure and ping gateway.sandbox.push.apple.com and make sure you have a good connection.

花落人断肠 2024-08-18 21:23:05

您必须将防火墙设置为允许所有 17.0.0.0/8 块(这一切都属于 Apple!)。检查这个答案

并根据苹果

APN 服务器使用负载平衡,因此您的设备不会始终连接到同一公共 IP 地址以获取通知。最好允许访问分配给 Apple 的整个 17.0.0.0/8 地址块上的这些端口。

如果您使用 CSF 防火墙(像我一样),我建议将此行添加到 csf.allow 文件中:

tcp|out|d=2195|d=17.0.0.0/8

然后重新启动 CSF 。使用上述内容而不是仅“17.0.0.0/8”将只允许与 Apple 的出站连接,特别是端口 2195。 NSA 不会喜欢它,但这样更精确和安全! ;)

You have to set your firewall to allow all the 17.0.0.0/8 block (it all belongs to Apple!). Check THIS ANSWER

And according to Apple:

The APNs servers use load balancing, so your devices won't always connect to the same public IP address for notifications. It's best to allow access to these ports on the entire 17.0.0.0/8 address block, which is assigned to Apple.

If you are using CSF firewall (like me), I'd recommend to add this line to csf.allow file:

tcp|out|d=2195|d=17.0.0.0/8

Then restart CSF. Using the above instead of just "17.0.0.0/8" will allow only outbond connections to Apple and specifically to port 2195. NSA won't like it but this is much more precise and safe! ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文