Thibault
Hi,
I used liveviews for a website. Everything works fine and the technology is really great. But I’m running into troubles with some customers behind proxy that won’t let websockets through properly.
With regular websockets, I have the option to enable longpolling for them. Is there a way to enable longpolling for live view too as a fallback (with a heavy performance hit, I’m aware, but better than nothing at all) ?
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m aware of 2 such projects, are there others?
git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
Hi everyone.
My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
Hello folks!
So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
How Can I Optimise Compile Time Dependencies
I have been building an elixir application for about 2 years now. Many modules and files ha...
New
Hi,
we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
Other Trending Topics
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with.
But I don’t use it anymore.
Serverless was the promis...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
chrismccord
It’s the same way you fallback to long polling when using channels. The LiveSocket constructor accepts the same options as Phoenix.Socket
Thibault
Indeed, I tried passing the longpolling parameter and it works in my dev environment (using Firefox and disabling the websocket with dev tools to test). Thanks !
But it does not work in production, it seems the fallback does not occur and the websocket keeps trying to connect. Maybe it’s because the server is behind HAProxy (yes, proxy on server side and proxy on client side, the joy of corporate environments). I will try to check with the hosting team.
My next option is to enable SSL to force the proxy to leave the websocket alone.
I’m marking your answer as a solution, since it works with normal cases…
florish
Hi @Thibault, I ran into this forum thread while investigating a seemingly similar issue with LiveView websockets not connecting specifically in corporate remote desktop environments.
I know it’s been a while since your last post, but did you have any luck finding a solution?
For reference for people googling for specific HTTP response codes in combination with LiveView: In our case, the websocket connection setup seems to get stuck after a HTTP 426 (Upgrade Required) response somewhere in the initial connection process.
Thibault
Sadly no. It was in a corporate environment (banking) and they felt that they could not secure web sockets in a satisfying manner. So any websocket was blocked by their corporate proxy and nothing to be done.
So I had to retrofit the application back to REST and vanilla JS. Thankfully that was actually surprisingly fast to do, by turning the live view into regular templated and sending responses as plain HTML over REST.
Live view is a marvelous technology, however adoption remain a problem with some companies that still live in the years 2000 (well, they dropped IE6 support at least).
benwilson512
Were you unable to get live view to work via HTTP long polling?
Thibault
Nope didn’t work either, everything went through a proxy and it did not seem to agree with long polling. And working from the outside made debugging extremely frustrating. Since it was a small project, it was faster to fall back to REST/HTML than to try to find a solution (when you’re start involving corporate IT in a bank, time starts counting in months).
chrismccord
The long poll transport is only Ajax so if REST/HTML works, then long poll will work. Did you make the following changes to your app.js and endpoint?
…
Thibault
I did make some tries with long polling and it did not seem to work.
But as I said, it’s pretty difficult to take in this kind of environment : I had no direct access to the production server, no access to the client network. This made testing an pretty frustrating process. So I must admit that I switched to plan B pretty quick in order not to lose too much money on the project.
I will test it again in this context if I have the opportunity to use if for a larger project.
florish
Thanks for the detailed response!
Just to be sure: that JavaScript snippet, should I be able to find that in the LiveView and/or
Phoenix.Socketdocumentation? I’m pretty sure I wouldn’t have added that as part of enabling long polling if I hadn’t read this forum thread.benwilson512
Hey @chrismccord in this issue Fallback to LongPoll not working on iOS · Issue #2914 · phoenixframework/phoenix · GitHub you sketched out a solution for falling back to long polling if the websocket cannot connect. Have you seen a similar mechanism one could write for this in live view? The linked solution involves writing callbacks to channel functions that you don’t have available to you in LV.