I am using GCM in combination with Google AppEngine (Java). My service sends more than 10.000 messages every day. Almost every message is successfully sent to the receiver. But about every day, I get the following exception after sending a GCM message via AppEngine:
Uncaught exception from servlet
java.io.IOException: Could not fetch URL: https://android.googleapis.com/gcm/send
at com.google.appengine.api.urlfetch.URLFetchServiceImpl.convertApplicationException(URLFetchServiceImpl.java:137)
at com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:43)
at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.fetchResponse(URLFetchServiceStreamHandler.java:417)
at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getInputStream(URLFetchServiceStreamHandler.java:296)
at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getResponseCode(URLFetchServiceStreamHandler.java:149)
at com.google.android.gcm.server.Sender.sendNoRetry(Sender.java:362)
at com.google.android.gcm.server.Sender.send(Sender.java:261)
at de.alamos.firemergency.apager.gcm.ApagerServlet.sendDataToAndroid(ApagerServlet.java:282)
at de.alamos.firemergency.apager.gcm.ApagerServlet.doPost(ApagerServlet.java:162)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
...
This error occurs at following line:
MulticastResult results = sender.send(message, tokens, 5);
Does anyone has an idea, what the problem could be?
It is quite strange, becuase 99,999% of all messages will be sent. Only a few of them are throwing this exception.
Here is the "solution": https://groups.google.com/forum/#!msg/google-appengine/vkD2ffMogAg/ntF_EkHYaxcJ
Summary: It is quite normal, that a few URL calls with AppEngine will fail. If the call fails, you just have to try it again.
I try to solve this with use of the AppEngine task queue.