Qminder / javascript-api

Javascript API for Qminder queue management system
https://www.qminder.com/docs/api/
Apache License 2.0
8 stars 2 forks source link

Multiple WebSockets are created when a content filter blocks WebSocket #588

Open boxmein opened 1 year ago

boxmein commented 1 year ago

When using the Javascript SDK in a browser, and a content filter that restricts WebSocket traffic is in place on the customer's computer, it is possible that multiple websockets are created.

The following sequence of events must occur:

  1. Consumer code calls Qminder.GraphQL.subscribe(...).subscribe(...)
  2. The Connection API key is fetched quickly
  3. The WebSocket initialization handshake starts and an error occurs (e.g. a HTTP 4xx/5xx reply during the handshake)
  4. Another part of consumer code calls Qminder.GraphQL.subscribe(...).subscribe(...) again
  5. The Connection API key is fetched quickly
  6. The WebSocket initialization handshake starts again
  7. The previous sleepMs() timeout introduced in #577 is not cancelled, and fires eventually
  8. ⚠️ A second WebSocket is created
boxmein commented 1 year ago

This does not appear to have a compounding effect, unlike #587 .

An appropriate fix would be to stop any pending waiting reconnection requests when attempting to connect again.

Prior art:

boxmein commented 1 year ago

Fixing this was left out of #577 due to #577's importance in providing high WebSocket delivery quality.