Laravel + Google Cloud Messaging (Connection timed

2020-02-13 03:38发布

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条回答
地球回转人心会变
2楼-- · 2020-02-13 04:22

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.

查看更多
登录 后发表回答