dblack
February 18, 2024, 11:07pm
1
I’ve noticed that when I kill and restart the Phoenix dev server, all existing browser tabs with a LiveView reconnect back to the server using longpoll (and stick to using longpoll). If I open a new tab, the LiveView connects using websocket.
I can’t say I’ve noticed this before, and I’m not sure if this is expected behaviour or something I’ve tweaked and set up wrong?
This snippet may help (it disables the fallback altogether in the dev env):
let liveSocket = new LiveSocket("/live", Socket, {
longPollFallbackMs: window.location.host.startsWith("localhost")
? undefined
: 3000,
...
})
This PR might address this issue…
main ← peymor19:longpoll_fallback_ms
opened 09:02PM - 19 Apr 25 UTC
When a browser client loses its web socket connection to the server, I noticed t… hat it immediately falls back to long poll without respecting the `longPollFallbackMs` delay.
This causes all connected browser clients to fall back to long poll when restarting an Elixir server, instead of attempting to reconnect to a new web socket as expected.
I have added a failing test and a potential fix.
I am not sure that the implementation of the fix is the best so I would appreciate some insight on the issue before diving deeper into a better solution.
In this image you can see that I set the `longPollFallbackMs` to 5500 ms

This image shows the client immediately falling back to long poll instead of waiting the 5500ms for a web socket connection.

Thanks for your consideration!