From d719643532bf500d5c014b4c1135db5101febb7d Mon Sep 17 00:00:00 2001 From: Oleksii Orel Date: Sat, 30 Nov 2019 23:39:57 +0200 Subject: [PATCH] add websocket stream check before sending a message (#15369) * Add WebSocket stream check before sending a message Signed-off-by: Oleksii Orel --- dashboard/src/components/api/json-rpc/websocket-client.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dashboard/src/components/api/json-rpc/websocket-client.ts b/dashboard/src/components/api/json-rpc/websocket-client.ts index 03bd2c2e147..d3a9eb77103 100644 --- a/dashboard/src/components/api/json-rpc/websocket-client.ts +++ b/dashboard/src/components/api/json-rpc/websocket-client.ts @@ -126,7 +126,11 @@ export class WebsocketClient implements ICommunicationClient { * @param data to be sent */ send(data: any): void { - this.websocketStream.send(data); + if (this.websocketStream) { + this.websocketStream.send(data); + } else { + console.log('Failed to send data. WebSocket stream isn\'t open.'); + } } /**