android - Laravel + Google Cloud Messaging(连接超时)

标签 android laravel push-notification google-cloud-messaging

我正在使用 Laravel 作为我的 Android 应用程序的后端服务器。 这是我用于发送推送消息的包:https://packagist.org/packages/davibennun/laravel-push-notification

我进行了所有设置(服务器端 + 客户端)并试了一下。 它发送消息没有任何问题,除了有时它会给我一个超时错误:

Zend \ Http \ Client \ Adapter \ Exception \ RuntimeException Unable to connect to android.googleapis.com:443 . Error #0: stream_socket_client(): unable to connect to android.googleapis.com:443 (Connection timed out)

我应该怎么做才能使其可靠?我想确保将消息发送到应用程序。

最佳答案

我遇到了同样的错误并试图找出原因。

这个错误有一定的可能性。

  1. 您的互联网防火墙阻止了与谷歌的连接:请尝试 ping android.googleapis.com 在你的 laravel 主机中。或 curl -v gcm-http.googleapis.com 如果没有响应则被阻止。

  2. 为 google api 打开你的端口,我通常打开端口 443 , 5528-2230。你可以在你的防火墙中配置

  3. gcm-http.googleapis.com 有很多 IP 地址,因此您需要允许来自这些 IP 地址的连接,这是它们的 IP 地址之一:172.217 .3.170我的通过允许他们的 ip 地址范围之间的连接来解决问题。您可以在防火墙软件中监控 IP 地址。

  4. 您可以找到 google api IP 地址的范围 herehere

这取决于您的防火墙配置,您需要与配置防火墙的人员一起设置这些配置,因为我假设您在安全网络环境中工作。

关于android - Laravel + Google Cloud Messaging(连接超时),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25116687/

相关文章:

php - 如何基于表格添加自定义列 - Laravel

laravel - NGINX 在创建符号链接(symbolic link)后给出 404 错误

php - 在 PHP laravel 框架中使用 webpack 和 react 不能热更新?

ios - 在 ios7 中更新推送通知的角标(Badge)计数

ios - 未通过网络应用程序从 Sinch 收到推送通知

android - 找不到列表 ID : android:list

android - 谷歌播放的版本控制

android - 向 android 中的特定受众发送推送通知

java - 事后如何添加依赖注入(inject)?

android - 使用 Xamarin.Android 我想将 sqlite 与 sql server 同步