GCM gives me random Unauthorized 401 errors (PHP CURL)

I just implemented my PHP server to send messages through Google Cloud Messaging to my Android device using CURL.

Everything works fine: I run the script, the message is sent and received successfully on my mobile device.

Or at least it happens sometimes. Sometimes it returns a 401 Unauthorized error. If I run the script 10 times, the error is about 1-4 times.

The only solution I can think of right now is to put all the code in a block while($unauthorized) { ... }

, so it will retry sending the message until it receives an HTTP 200 response.

Any other suggestions? Has anyone else experienced this? What could be causing this behavior?

+3


source to share





All Articles