Sanjibukai

Sanjibukai

Hi there,
I’m testing Phoenix Websocket by using this simple echo server example from the doc: Phoenix.Socket.Transport — Phoenix v1.8.8

For testing purpose I added a longer timeout of 10 minutes instead of the default 60s:

socket "/socket", EchoSocket, websocket: [timeout: 600_000], longpoll: false

The timeout config seems to work on my local machine as it no longer disconnects.
BTW, I added a simple logging of the :reason in the terminate callback and upon timeouts I get as expected :timeout.

However, on the server, it doesn’t work..
Well, it seems the timeout config is taken into account as it doesn’t disconnect after the default 60s..
But it still disconnects a little bit later…
In fact it disconnects exactly 100s after the connection is established.. Or 100s after the last message sent or received.
And when it happens, the reason is {:error, :closed} which doesn’t tell much about what’s going on.

The fact it’s very regular (exactly 100s) makes me thing it’s not related to Phoenix but most probably to the server itself (probably Linux related config).. But I have no clue how to diagnose this.. The server is running Debian if it can help.

Is anyone have an idea on how to investigate?
Or where I can ask about this issue?

Thank you very much.

Edit:
I read about TCP keepalive settings: Using TCP keepalive under Linux
I have the same values 7200, 75 and 9 on both my machine and on the server. So I guess it’s something else..

Showing Posts 1 to 3

Hermanverschooten

Hermanverschooten

Are you connecting to Phoenix directly on the server or through a reverse proxy?

Sanjibukai

Sanjibukai OP

I’m using a reverse proxy indeed which is caddy..
And now you mentioned this, it makes sense that my issue might be related to it..
However I’m not editing it and it seems the default is either 2m or 30s: reverse_proxy (Caddyfile directive) — Caddy Documentation
In my case I have a consistent 100s..

I’ll try to investigate further around caddy..

Miyagi

Miyagi

I’m having similar issues. The timeout config doesn’t seem to have any effect.

In a local setup:
I tried setting it to 2s (not practical in the real world) to force connection error on my clients (local dev browsers / no reverse proxy in bw). However their socket connection doesn’t close / no failure in browser console. No presence leave event (on the other connected clients)

My socket config:

socket “/socket”, App.UserSocket,

websocket: [ timeout: 2000]],

longpoll: false

I’m running Bandit webserver:


config :surya, App.Endpoint,

adapter: Bandit.PhoenixAdapter,

...

protocol_options: [

idle_timeout: 15_000

]

What I am trying to achieve: I want to change the default timeout so that connection loss, triggers a presence left event sooner than the defaults.

Background (How I got here): In production, I set it to 15s on server with 7.5s heartbeat on clients, but noticed no effect on the app (this setup does run behind caddy tho).

I think I’m getting confused bw heartbeat timeout (channel protocol), and keep-alive settings (http protocol).

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews