jcorrea

jcorrea

Bandit websocket server connection terminated reason={:error, :closed}

Hi everyone! :waving_hand:

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?

Thanks in advance!

Most Liked

krasenyp

krasenyp

If this is deployed somewhere, it might be your infrastructure provider not allowing long-lived connections.

Last Post!

jcorrea

jcorrea

Yes, that definitely makes sense!

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.

Where Next?

Popular in Questions Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New

We're in Beta

About us Mission Statement