jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error:
WebSocket connection to 'wss://web.my-app.convox/socket/websocket?userToken=726&vsn=1.0.0' failed: Error during WebSocket handshake: Unexpected response code: 403
I have also tried ws:// instead of wss:// and got the same result.
I used to have BasicAuth running in my app, but I have removed it.
My user_socket.ex file is as follows:
defmodule MyAppWeb.UserSocket do
use Phoenix.Socket
## Channels
channel "vw:*", MyAppWeb.VowpalWabbitChannel
## Transports
transport :websocket, Phoenix.Transports.WebSocket, check_origin: false
def connect(_params, socket) do
{:ok, socket}
end
def id(_socket) do
nil
end
end
What can i do to connect to my websocket in a non-dev environment?
Thanks.
Trending in Questions
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
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
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
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
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
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
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
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
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
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
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 12 to 3- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
namosca
Hi, I was having this problem and your answer worked. I had to change it in user_socket.ex and prod.exs.
baldmountain
@jononomo I just ran into this too. The way I fixed it is to use the
check_originoption as suggested above, but instead of setting itfalseset it to a list of domains likewhere
mycoolwebsite.comis the domain for your DigitalOcean Docker container.Ryzey
Did you ever solve this? I am having the same problem. Websocket works on localhost but get 403 Forbidden when deployed on DigitalOcean in a Docker container.
jononomo
@matiso Yes, my intention is to add the security back in one step at a time, but first I just want to be able to connect to my websocket.
matiso
From a security perspective, I would defintely not recommend disabling the origin check. It’s there for a reason, and disabling it to “just make it work” isn’t the right way to go.
IF your issue has to do with the origin, make sure to provide a whitelist of allowed origins, instead of completely disabling the check.
karmajunkie
Yep, i missed that in your earlier message. Those are the only places you’d need to set it AFAIK. If its still an issue you’ll probably want to try to create a minimal reproduction repo and post a link here or ask on the slack phoenix channel.
Looking at your error, if you’re getting a 403 it may also be your authentication mechanism. Have you got any plugs like guardian that might be returning the 403 before your socket authenticates? You said earlier that you’d removed the Basic auth, so if that’s your only authentication you probably shouldn’t be getting a 403.
jononomo
Isn’t this line doing it on the socket transport as well?
karmajunkie
You’ll probably want to do that in your socket transport as well, see options on the transport documentation: https://hexdocs.pm/phoenix/Phoenix.Transports.WebSocket.html#content
jononomo
Thanks, @karmajunkie – I have set check_origin to false in both my user_socket.ex file as follows:
and also in my
prod.exsfile as follows:Is there any other place where I would need to set check_origin to false?
karmajunkie
You probably want to set the
check_originoption. By default I believe its whatever protocol, host, and port you set your host to. You’ll need to add any additional hosts to it there.