Liveview unable to connect to websocket

I recently updated* an application that makes minimal use of LiveView, I think we have it on two pages but one is pretty critical. Since the updates the LiveViews have been unable to connect to web sockets. I’ve seen similar issues where the error message specified a handshake error but in this case what I’m seeing is:

app-f5ba9ec5af210758132be0869eb54750.js?vsn=d:29 WebSocket connection to 'wss://example.site.com/live/websocket?_csrf_token=AXhtHDEDFSI7YgQnGXlsC3lhLjMkQB0d1A7YKZvkYOvjxLXbLVDqGvzQ&_mounts=0&vsn=2.0.0' failed: 

value	                            @	app-f5ba9ec5af210758…eb54750.js?vsn=d:29
t	                                @	app-f5ba9ec5af210758…eb54750.js?vsn=d:30
value	                            @	app-f5ba9ec5af210758…eb54750.js?vsn=d:30
(anonymous)	                        @	app-f5ba9ec5af210758…eb54750.js?vsn=d:40
t.dispatch	                        @	turbo-9350e2549702da…102154c8.js?vsn=d:6
n.notifyApplicationAfterPageLoad	@	turbo-9350e2549702da…102154c8.js?vsn=d:7
n.pageLoaded	                    @	turbo-9350e2549702da…102154c8.js?vsn=d:7
(anonymous)	                        @	turbo-9350e2549702da…102154c8.js?vsn=d:7

I’m sort of shooting in the dark on my troubleshooting. I’ve liveSocket.enableDebug() but since the websocket dosen’t connect, I’m assuming, it’s not going to give me much info. After reloading I do get, join: encountered 202 consecutive reloads but I assume that’s because it’s just tracking the attempts.

The Nginx config has not changed.

*Erlang 22.2 → 24.2
Elixir 1.10.4 → 1.13
Phoenix 1.4.17 → 1.5.13
Still using LiveView 0.13.3

What type of update did you make? And are there any errors on the server side?

Ah sorry, markdown took my asterisk and turned it into a bullet point. The updates were just the updates I listed at the end of my post.

As far as server side errors, I’m not seeing any in the journal. At one point, I had misconfigured the check_origin. LiveView made sure I knew about it, but that’s no longer an issue.

Oh, I finally figured it out… This was the issue, I had upgraded from plug_cowboy 1.0.0 to 2.5.2. You have to add proxy_http_version 1.1; to the location block.

1 Like

A coworker with the same issue dug this up and I was properly confused by my answer… I should clarify, then I was talking about the “location block” I was referring to the Nginx config in sites-available not an Elixir thing:

server {
   ...
   location @subdomain {
        proxy_http_version 1.1;
  }
}