diff --git a/src/connector/signaling/signaling-client.ts b/src/connector/signaling/signaling-client.ts index 1509890..99ddf74 100644 --- a/src/connector/signaling/signaling-client.ts +++ b/src/connector/signaling/signaling-client.ts @@ -143,10 +143,14 @@ export const SignalingClient = (input: { const sendMessage$ = of(stringify(encryptedMessage)).pipe( tap((result) => result.map((data) => { - logger?.trace( - `🛰💬⬆️ sending: ${message.method} (${encryptedMessage.requestId})`, - ) - return ws.send(data) + const incorrectStates: number[] = [ws.CLOSED, ws.CLOSING] + if (!incorrectStates.includes(ws.readyState)) { + logger?.trace( + `🛰💬⬆️ sending: ${message.method} (${encryptedMessage.requestId})`, + ) + + return ws.send(data) + } }), ), filter(() => false),