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 Answer
1
Accepted Answer

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
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions