Amplify PubSub AWSIoTProvider in multiple browser tabs

0

We have a web browser application (angular) using Amplify PubSub with Cognito authentication. Everything is working correctly in a single window: connect, publish, subscribe all working.

However, if one of our users opens a second browser tab/window for the application, the original window disconnects with the error:

MqttOverWSProvider errorCode:8 AMQJS0008I Socket closed

In our application it is quite common for it to be open in more than one tab/window at the same time.

Is there a setting or something we need to do in order to prevent disconnection in the first open tab?

1 回答
1
已接受的回答

The description of the behavior suggests you have a client ID conflict. Only one active connection can use a distinct client ID. If a second connection succeeds and uses the same client ID as another connection, the service behavior is to disconnect the existing session. Does your application pass a value to the PubSub provider? It looks like if no client ID is explicitly defined, the provider will create a new UUID. https://github.com/aws-amplify/amplify-js/blob/a047ce73/packages/pubsub/src/Providers/MqttOverWSProvider.ts#L38

AWS
Ryan_B
已回答 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则