Unexpected refreshes on LiveView pages

I am using LiveView for some of my pages on my website. I noticed those pages getting hundreds of requests from the same IPs. This happens on most of the LiveView pages and from different IPs. Each request is about one minute apart (see logs below).

I cannot get to reproduce this behavior so I have no idea how to fix this. Has anybody experiences this before?
My guess is that the websocket connection gets disconnected? Is there a way to stop a LiveView page from attempting to reconnect after like ~10 disconnects?

Example page: https://listudy.org/en/motif
Code: https://github.com/ArneVogel/listudy/blob/master/lib/listudy_web/live/motif_search_live.ex
About the server setup: the app is running on my server with Caddy in front of it.

Small exerpt from the logs, this ip has made 467 of these request alone today.

SAME_IP - - [01/Dec/2020:09:51:47 +0000] "GET /en/motif HTTP/2.0" 200 3189 - "https://listudy.org/en/motif"
SAME_IP - - [01/Dec/2020:09:52:47 +0000] "GET /en/motif HTTP/2.0" 200 3193 - "https://listudy.org/en/motif"
SAME_IP - - [01/Dec/2020:09:53:39 +0000] "GET /en/motif HTTP/2.0" 200 3192 - "https://listudy.org/en/motif"
SAME_IP - - [01/Dec/2020:09:54:32 +0000] "GET /en/motif HTTP/2.0" 200 3192 - "https://listudy.org/en/motif"
SAME_IP - - [01/Dec/2020:09:55:17 +0000] "GET /en/motif HTTP/2.0" 200 3190 - "https://listudy.org/en/motif"
SAME_IP - - [01/Dec/2020:09:56:17 +0000] "GET /en/motif HTTP/2.0" 200 3189 - "https://listudy.org/en/motif"

Browsers will disconnect websockets, at different periods of time, when tabs are on the background. Each browser will have different behaviour but Safari is generally more aggressive. I don’t think stop reconnecting is a good idea, because if users eventually go back to those tabs, then it will unresponsive, but maybe LiveView should be reconnecting the websocket instead of reloading the page. It may not be possible though, because browsers don’t usually tell you that they are the ones who disconnected.

Thanks for the input.

I will look into it if that is possible with LiveView.

I understand why you suggest not to stop the reconnecting. But I am worried that this behaviour will become a self-made DDoS in the future. Currently it’s no problem but I am a bit worried about the future if the site would become bigger.

I have updates! The LV behaviour today is correct: it tries to reconnect the websocket without reloading the page. Maybe reconnecting is failing for some reason? Either a bug in the app or the browser is blocking it.

1 Like