Messages from prior state being received after ws reconnect

15 Views Asked by At

I have an app which connects to a public websocket server (no auth, and I don't control it).

I observe that when I initiate a reconnection myself, upon reconnect my client immediately receives a couple of messages which relate to the state in the connection prior to the disconnection.

I have a few hypotheses for why it happens, perhaps someone can shed some light on this:-

  1. if you disconnect and reconnect "quickly enough" then you're recognised by the server, which picks up where it left off by continuing to send messages from the context before the reconnection
  2. it's part of the websocket protocol itself, or some other layer of the network stack
  1. it's server implementation specific, perhaps the implementer configures some cache ttl for client contexts and buffers messages for a short time for each client
  2. it's client implementation specific, maybe the messages were in my local buffer before I disconnected and for some reason in the particular websocket library they're still accessible after the reconnect / some resource isn't being fully dropped between connections

Does it depend or is there some blanket explanation for this behaviour?

0

There are 0 best solutions below