Laravel + Google Cloud Messaging (Connection timed out)

那年仲夏 提交于 2019-12-18 07:14:20

问题


I am using Laravel as Backend server for my android application. Here is the package I used for sending push messages: https://packagist.org/packages/davibennun/laravel-push-notification

I made all settings (server-side + client-side) and gave it a try. It sends messages without any issue, except sometime it gives me a timeout error:

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)

What should i do to make it reliable? I want to make sure that message is sent to the app.


回答1:


I've got the same error and trying to figure it out why.

There are some possibility for this error.

  1. Your internet firewall block the connection to the google : pls try ping android.googleapis.com in your laravel host. or curl -v gcm-http.googleapis.com if doesn't response then it is blocked.

  2. Open your the port for google api to work, I open the port usually 443 , 5528-2230. you might configure in your firewall

  3. the gcm-http.googleapis.com has a lot of ip addresses, so you need to allow connection from these ip addresses this is one of their ip address : 172.217.3.170. mine solve the problem by allowing the connection between the range of their ip addresses. you can monitor the ip address in your firewall software.

  4. you can find the range of google api IP addresses here and here

it depends on your firewall configuration you need to setup those with the guy who configure the firewall since I assume you work in the secure network environment.



来源:https://stackoverflow.com/questions/25116687/laravel-google-cloud-messaging-connection-timed-out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!