Liveview form keeps on refreshing every 15s

Here is what I additionally found out.
If I try to set the timeout to 2s, the problem gets worse.
Having a look at the console, for some reason, the websocket connection gets closed. I can’t figure out why.

By looking at the screenshot, I wonder if it isn’t because the heartbeat message is sent too early

Forgot to mention, my problem is happening when the user is active on the tab, not when the tab is in the background (otherwise that would not be a problem).

Ok it definitely looks like on a too short heartbeatintervalMs, the websocket closes the connection. So I increased it to 10s. The logic behind this is to give time to slow clients on a bad network connection to load the page. I am trying to reduce the timeout to 5s and see how things get affected.

timeout 5s was way too short, the page kept on reloading.
I’ve finally settled for 10s heartbeat and 10s timeout.
For some reason it looks like the websocket server response comes slowly sometimes. (5s and above).
I guess I just have to have metrics for those and keep an eye on them.
I’ve doubled checked and my server only has 50-100 concurrent websockets at once. So not really sure why there is a slow response. I am going through cloudflare though, maybe that is a factor. It makes me think that unfortunately, I shouldn’t be using liveview on form pages. The problem of reloading while the user inputs is just too big.