订阅主题突然抛出“java.io.IOException:InternalServerError” [英] Subscribe to topics suddenly throws "java.io.IOException: InternalServerError"

查看:828
本文介绍了订阅主题突然抛出“java.io.IOException:InternalServerError”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从今天我遇到以下问题与GCM订阅主题。
Nexus 6,Android 6.0.1,Google Play服务9.0.83
在应用中使用google-play-services:8.3.0。

第1步

我遵循Google的文档,实例ID。
获取令牌后,我成功订阅主题/全局主题并将令牌存储在共享首选项中。

  SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); 

尝试{
// [START register_for_gcm]
//最初,这个调用发送到网络以检索令牌,后续调用
//是本地的。
// R.string.gcm_defaultSenderId(发件人ID)通常来自google-services.json。
//有关此文件的详细信息,请参阅https://developers.google.com/cloud-messaging/android/start。
// [START get_token]
InstanceID instanceID = InstanceID.getInstance(this);
String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
GoogleCloudMessaging.INSTANCE_ID_SCOPE,null);
// [END get_token]
Log.i(TAG,GCM注​​册令牌:+令牌);

// TODO:实施此方法将任何注册发送到您应用的服务器。
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
sharedPreferences.edit()。putString(token,token).apply();


//您应该存储一个布尔值,指示生成的令牌是否已经发送到您的服务器
//。如果布尔值为false,则将令牌发送到您的服务器
//否则您的服务器应该已经收到该令牌。
sharedPreferences.edit()。putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER,true).apply();
// [END register_for_gcm]
} catch(Exception e){
Log.d(TAG,无法完成令牌刷新,e);
//如果在获取新标记或在第三方服务器上更新我们的注册数据
//时发生异常,这可确保我们稍后尝试更新。
sharedPreferences.edit()。putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER,false).apply();
}
//通知UI注册已完成,因此可以隐藏进度指示器。
Intent registrationComplete = new Intent(QuickstartPreferences.REGISTRATION_COMPLETE);
LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
}

第2步

经过一段时间/用户交互后,我想订阅其他主题。
我从共享首选项中获取令牌,并尝试像以前一样订阅,但是这次它失败并显示java.io.IOException:InternalServerError。
当然会遇到异常,但我现在不知道该怎么做。

  private void subscribeTopics()抛出IOException {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
String token = sharedPreferences.getString(token,null);
if(token == null){
Log.e(TAG,No token);
return;
}

GcmPubSub pubSub = GcmPubSub.getInstance(this);
for(String topic:TOPICS){
pubSub.subscribe(token,/ topics /+ topic,null); //< --- FAILS HERE
}
Log.d(TAG,订阅主题。
}

这个过程在过去5个月中没有问题。突然,从今天上午开始,订阅其他主题(步骤2)失败。
如果切换到Firebase云消息传递(FCM)带来突破性变化,是否有任何想法?



目前我的所有客户端应用程序都无法使用。
快速帮助真的很感谢。

解决方案

我是Google Cloud Messaging团队的一员。 b
$ b

我们在我们的支持中发现了一个问题,它在过去24小时内影响了一小部分主题订阅。
问题已经解决,订阅应该在所有设备上正常工作。



请让我们知道您是否仍然遇到此错误。 p>

感谢Steffen报告此问题。


since today I encountered the following issue with GCM "subscribe to topics". Nexus 6, Android 6.0.1, Google Play Services 9.0.83 Using google-play-services:8.3.0 in app.

Step 1

I follow the documentation from Google for getting the token through the instance id. After getting the token I successfully subscribe to the "topics/global" topic and store the token in the shared preferences.

protected void register() {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    try {
        // [START register_for_gcm]
        // Initially this call goes out to the network to retrieve the token, subsequent calls
        // are local.
        // R.string.gcm_defaultSenderId (the Sender ID) is typically derived from google-services.json.
        // See https://developers.google.com/cloud-messaging/android/start for details on this file.
        // [START get_token]
        InstanceID instanceID = InstanceID.getInstance(this);
        String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
                GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
        // [END get_token]
        Log.i(TAG, "GCM Registration Token: " + token);

        // TODO: Implement this method to send any registration to your app's servers.
        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
        sharedPreferences.edit().putString("token", token).apply();


        // You should store a boolean that indicates whether the generated token has been
        // sent to your server. If the boolean is false, send the token to your server,
        // otherwise your server should have already received the token.
        sharedPreferences.edit().putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, true).apply();
        // [END register_for_gcm]
    } catch (Exception e) {
        Log.d(TAG, "Failed to complete token refresh", e);
        // If an exception happens while fetching the new token or updating our registration data
        // on a third-party server, this ensures that we'll attempt the update at a later time.
        sharedPreferences.edit().putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false).apply();
    }
    // Notify UI that registration has completed, so the progress indicator can be hidden.
    Intent registrationComplete = new Intent(QuickstartPreferences.REGISTRATION_COMPLETE);
    LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
}

Step 2

After some time / on user interaction I want to subscribe to additional topics. I fetch the token from the shared preferences and try to subscribe like before, but this time it fails with the "java.io.IOException: InternalServerError". The exception is catched of course, but I do not know how to proceed now.

private void subscribeTopics() throws IOException {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    String token = sharedPreferences.getString("token", null);
    if(token == null) {
        Log.e(TAG, "No token");
        return;
    }

    GcmPubSub pubSub = GcmPubSub.getInstance(this);
    for (String topic : TOPICS) {
        pubSub.subscribe(token, "/topics/" + topic, null);  // <--- FAILS HERE
    }
    Log.d(TAG, "Subscribed to topics.");
}

This process worked for the last 5 months without issues. Suddenly, since this morning, the subscription to additional topics (step 2) fails. Any idea if the switch to Firebase Cloud Messaging (FCM) brought breaking changes?

Currently all my client apps are not usable. Fast help is really appreciated.

解决方案

I am part of the Google Cloud Messaging team.

We identified an issue in our backed that affected a small percentage of the topic subscriptions during the last 24 hours. The issue has already been fixed, and the subscriptions should work correctly on all devices.

Please let us know if you are still experiencing this error.

Thanks Steffen for reporting the issue.

这篇关于订阅主题突然抛出“java.io.IOException:InternalServerError”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆