I’m building a WebSocket server with Bandit inside a Plug app, and the experience has been fantastic so far, really clear semantics and great performance out of the box.
I’ve run into one issue, though: I occasionally see connections terminate with {:error, :closed}. I’m trying to figure out the best way to diagnose what’s causing these closures, since there’s nothing in the server logs that seems to explain them, and our code never returns a {:stop, reason, state}.
Has anyone dealt with this before or have suggestions on how to track down the source of these disconnects?
Additionally, in my testing I noticed that some WebSocket clients don’t actually send a close frame or status code when they disconnect, they just close the underlying TCP connection. That was a bit surprising and explains why the server sees it as an abrupt disconnect rather than a regular shutdown, which in turn makes it harder to differentiate network interruptions from regular application-level connection terminations.