We have been using Phoenix live view in one of our projects. It is deployed under Proxy.
I find that WebSockets won’t work under a proxy. So alternate solution is using long poll.
I want to know two things.
- we are using Phoenix 1.5
app.js
import {Socket} from "phoenix"
import NProgress from "nprogress"
import {LiveSocket} from "phoenix_live_view"
let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content")
let liveSocket = new LiveSocket("/live", Socket, {params: {_csrf_token: csrfToken, transport: LongPoll}})
endpoint.ex
socket "/live", Phoenix.LiveView.Socket,
websocket: [connect_info: [session: @session_options]],
longpoll: true
I have changed the connection from WebSocket to the long poll. But things are not working after I made these two changes.
I made only the two changes which are mentioned above. What I have done wrong or what I am missing to make it work in long poll.
- Performance-wise does the Phoenix live view will it go down since because I have used Longpoll instead of WebSocket? Is there any alternative available?
Any insight on these two questions will be a great help for me. Your help is greatly appreciated. Thanks.