React hook websockets failing on unmount preventing future reconnects
TS bindings and ledger version 1.18.1
When a react component using the useStreamQueries hook is unmounted the websocket fails with:
WebSocket connection to ‘ws://localhost:7575/v1/stream/query’ failed: WebSocket is closed before the connection is established.
When you then navigate back/cause the component to render again. The websocket refuses to connect again with the error:
useStreamQueries: WebSocket connection failed.
reconnectThreshold doesn’t change this behavior
Hi @Turan, thanks for raising this. This is a known issue in 1.18.x releases. It’s due to an experimental feature (multiplexing HTTP JSON API streams over a single WebSocket) that was enabled by default but that turned out to have a flaky behavior. This experimental feature has been turned off by default starting from 2.0.0 (PR here) and I recommend you upgrade to the latest version.