ditto-clients icon indicating copy to clipboard operation
ditto-clients copied to clipboard

[JS] Buffered WebSocket client sends messages before being connected

Open ffendt opened this issue 3 years ago • 0 comments

The buffered implementation for WebSockets has bug that it will try to send the buffered messages to the WebSocket before the WebSocket has finished connecting.

From what I can observe now, the problematic code can be found in StandardResilienceHandler#addToOutstandingBuffer. In this function, an outstanding request is added to the buffer and a timeout is started for calling #poll(). The #poll() function however does not verify if this.webSocket is already initialized.

In case the connection takes longer than the initial timeout of 500ms, this.requestBuffer#sendNectOutstanding will be called with an undefined WebSocket and crash.

ffendt avatar May 26 '21 13:05 ffendt