Phoenix LiveView Socket phx_join timeout

Hi,

I have a problem where a LiveView page is slow to load, resulting in the user seeing the page being reloaded over, and over.

I recreated it locally by doing this in the LV’s mount by just doing this:

:timer.sleep(20_000)

This results in the phx_join timing out. The page then reloads every ~15’ish seconds.

I can’t figure out how to fix this.
I tried increasing the timeouts in my Endpoint:

  socket "/socket", StykkaWeb.UserSocket,
    websocket: [compress: false, timeout: 60_000],
    longpoll: false

  socket "/live", Phoenix.LiveView.Socket,
    websocket: [connect_info: [session: @session_options], timeout: 60_000]

Also tried this in my client:

let liveSocket = new LiveSocket("/live", Socket, { params: { _csrf_token: csrfToken, timeout: 60000 }, hooks: Hooks });

but the timeout is unchanged.

How do I increase the timeout on my LVs?

1 Like

Seems like this does the trick!

let liveSocket = new LiveSocket("/live", Socket, { params: { _csrf_token: csrfToken }, timeout: 60000, hooks: Hooks });
3 Likes