YoungFlannagan

YoungFlannagan

Hi all,

I deployed my elm embedded phoenix application to heroku and it compiled successfully. The issue I am having is the websocket connection no longer works. I am using the elm-phoenix-socket package, and figured all I had to do was change the socket init url from “ws://localhost:4000/socket/websocket” to “wss://my-app.herokuapp.com/socket/websocket” I have tried a couple other urls to no avail.

Not sure what to try. Any help would be appreciated.

Showing Posts 1 to 6

OvermindDL1

OvermindDL1

Did you update the allowed incoming url’s in your configuration?

apoeco

apoeco

Can you try wss://my-app.herokuapp.com/socket instead?
I am not sure if this will work but the default url defined in the Endpoint module is "/socket" ..

YoungFlannagan

YoungFlannagan OP

I have url: [scheme: "https", host: "secret-sea...herokuapp.com", port: 443] within my Endpoint config in prod.exs. Not sure if that is what you are referring to or not.

Most

Most

I ran into a similar problem and documented some of the different things I tried to fix it in this SO post.

I never got it to work properly and resorted to hard-coding my socket variable before pushing to production. If there’s a right way to accomplish this I’d love to know.

happysalada

happysalada

heroku gives an error about setting the check_origin parameter for me that did it

url: [scheme: “https”, host: “myapp.com”, port: 443],
check_origin: [
https://myapp.com”,
https://www.myapp.com
],

domvas

domvas

I’ve had a hard time with it too.
And I managed to tackle in non-so-satisfying way.
In my controller, I have this:

socket_prefix = get_socket_prefix(Application.get_env(:vinculi_web, :env))    
socket_host = get_socket_host(conn, Application.get_env(:vinculi_web, :env))
socket_url = socket_prefix <> "://#{socket_host}" <> "/socket/websocket"
render conn, "explore.html", layout: {VinculiWeb.LayoutView, "app_light.html"},
                                     node_uuid: node_uuid,
                                     node_labels: node_labels,
                                     server_url: server_url,
                                     socket_url: socket_url

with the following helpers:

def get_socket_prefix(:prod), do: "wss"
def get_socket_prefix(_), do: "ws"
def get_socket_host(conn, :prod), do: conn.host
def get_socket_host(conn, _), do: "#{conn.host}:#{conn.port}"

And I didn’t add any check_origin.

Again, this is not an elegant solution but it works (for me, at least) and don’t require tricks before pushing to production.
Hope it helps.

— All posts loaded —

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews