aws / amazon-chime-sdk-js

A JavaScript client library for integrating multi-party communications powered by the Amazon Chime service.
Apache License 2.0
704 stars 475 forks source link

Handle exceptions during messaging session Websocket reconnection #2928

Open GalenBry opened 1 month ago

GalenBry commented 1 month ago

What are you trying to do?

I am looking for a way to catch exceptions during messaging client Websocket retry/reconnect. Our application is reporting thousands of errors like this "Event CloseEvent (type=close) captured as promise rejection". We don't have access to a full stack trace unfortunately, but it appears to be coming from DefaultMessagingSession during a users session (specifically, after some time). Looking into the source for DefaultMessagingSession, it looks like you can catch an error when initially calling session.start(), but how would I catch an error if the DefaultMessagingSession detects the Websocket has closed and decides to reconnect? The Promise for that operation is not exposed to my knowledge. This causes a lot of noise, and also reveals that there is no way to handle errors during Websocket reconnect.

How can the documentation be improved to help your use case?

Include a way to handle errors during Websocket reconnection.

What documentation have you looked at so far?

Amazon Chime SDK Developer Guide Amazon Chime SDK API Reference Github Issues StackOverflow

ltrung commented 2 weeks ago

@GalenBry Thanks for submitting issue. Have you tried to use the messaging session observer event messagingSessionDidStartConnecting to catch if it is reconnect https://github.com/aws/amazon-chime-sdk-js/blob/main/src/messagingsessionobserver/MessagingSessionObserver.ts#L8