android – 尝试发送gcm消息时的HttpRetryExcepiton

尝试从我的服务器向GCM服务器发送消息时,我收到了
java.net.HttpRetryException异常.

try {
    multiResult = sender.send(message, devices, RETRY_COUNT);
} catch(IOException e) {
    logger.error("{0}\t- ANDROID : IOException occured during sending message: {1}", e.getMessage());

}

我已经成功注册了设备,但是这个send方法给了我异常,如下所示

java.net.HttpRetryException: cannot retry due to server authentication, in streaming mode
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
at com.google.android.gcm.server.Sender.sendNoRetry(Sender.java:362)
at com.google.android.gcm.server.Sender.send(Sender.java:261)

非常感谢任何帮助,谢谢

最佳答案 我想我找到了原因,我试图用错误的apikey发送通知,这是一个安卓密钥,谷歌说它应该是服务器密钥(浏览器密钥也可以)

点赞