无法使用 AWSIotMqttManager 和 Aws Cognito 凭证连接到 Aws Iot

Pun*_*dal 5 java android amazon-cognito aws-iot aws-amplify

我正在使用 AWS Cognito 登录并获取临时凭证。我在浏览器的 Ionic 应用程序中尝试了 PubSub API,它对于设备影子更新工作正常。现在我已经用 Java 为 android 编写了代码,但 MqttManager 一直在重新连接。

这是 Ionic 4 + Capacitor 插件中的原生代码

@PluginMethod()
    public void Init(PluginCall call)
    {
        String clientId = call.getString("clientId", null);
        if(clientId == null)
        {
            UUID uuid = UUID.randomUUID();
            clientId = uuid.toString();
        }
        mqttManager = new AWSIotMqttManager
        (
                clientId,
                "m6jklghidefabc-ats.iot.us-west-1.amazonaws.com"
        );

        String id = AWSMobileClient.getInstance().getIdentityId();
        if(id == null)
        {
            call.reject("Could not get identity id");
            return;
        }
        else
        {
            Log.i("Plugin===", id);
        }

        //
        //  Connect MQTT Manager
        //
        try
        {
            MqttPlugin th = this;
            mqttManager.connect(AWSMobileClient.getInstance(), new AWSIotMqttClientStatusCallback()
            {
                @Override
                public void onStatusChanged(final AWSIotMqttClientStatus status, final Throwable throwable)
                {
                    Log.i("Plugin====", status.toString());

                }
            });
            JSObject ret = new JSObject();
            ret.put("clientId", clientId);
            call.resolve(ret);

        }
        catch (final Exception e)
        {
            Log.i("Plugin==E=", e.getMessage());
            call.reject(e.getMessage());
        }
    }
Run Code Online (Sandbox Code Playgroud)

状态是正在连接然后正在重新连接...重新连接不断打印在 Logcat 请告诉我为什么当 AWS Cognito 的身份验证工作正常时无法连接。我的政策似乎已经到位,因为从浏览器我可以在 Ionic 4 应用程序中使用 PubSub api 进行连接