riverside

riverside

MyApp problem or mobile browser problem or both?

Howdy everyone!

I have a LiveView site that keeps refreshing when the connection is almost completed within the iOS instagram browser. Navigating around the site still works, but there is a problem with a live component working with a phx-click. This is giving me the idea that the socket is not establishing.

The problem does not occur when using mobile brave or safari. And the site runs smooth on the desktop.

Anyone has general pointers what i should do?
Adjust the http headers?
Adjust the endpoint.ex file?
Or let it be and figure out how to force a message to display a link to redirect the site to be viewed on a phone’s default browser?

And no i have not tried seeing if it happen’s in another social media app’s built in browser. But probably the same thing happens if a web socket isn’t allowed to be fully be established within the app’s internal browser, no?

Pretty lost at this point, any tips and tricks will help. Thanks in advanced.

Most Liked

lucaong

lucaong

I can reproduce the issue on Safari for Mac, so it does not seem to be a problem with the Instagram in-app browser only.

One thing I notice is this error:

Refused to connect to wss://garageratz.com/live/websocket?_csrf_token=...
...because it does not appear in the connect-src directive of the Content Security Policy.

I think the problem is that Phoenix LiveView JS fails to connect to the channel due to a CSP violation, and therefore triggers a reload after a timeout. The violation seems to be that your Content-Security-Policy header contains connect-src 'self';. According to MDN:

‘self’ Refers to the origin from which the protected document is being served, including the same URL scheme and port number.

So wss://garageratz.com/... is disallowed, because it uses a different URL scheme than https://garageratz.com.

Note that Chrome is more permissive than Safari when it comes to CSP, which explains why the issue does not occur on Chrome. See this issue for details.

lucaong

lucaong

I can confirm that on Safari for Mac now the websocket connects fine, and the page does not reload anymore. I do not have Instagram myself, so I cannot check there, but the CSP issue seems fixed. If the reload still happens on Instagram, it could be a bug specific to that context.

soup

soup

I am unable to see any issue on Safari 14.2 unfortunately. You could try something like https://www.browserstack.com/ if you don’t have access. I’ve not used it personally though, cant say if its worth the time (and money) or not.

Do you have the correct host, scheme and port set in your config/runtime|prod.exs?

I _dont_ think this would be the actual issue here (you (should?) would see other browsers misbehaving), but you never know with browsers TBH.

Can you see the user agent logs from an instagram request? Might give you a clue as to which webkit/safari build to check into.

Also does is occur when running on your dev machine? (Probably need to make a burner account to point to your local network address to test this in the app.)

Where Next?

Popular in Questions Top

Kurisu
For example for a current url like http://localhost:4000/cosmetic/products?_utf8=✓&query=perfume&page=2, I would like to get: ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New

Other popular topics Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29377 241
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52341 488
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39297 209
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

We're in Beta

About us Mission Statement