archimondain
I receive the error
Error during WebSocket handshake: Unexpected response code: 500
in my browser.
The Phoenix code is
defmodule SyntaxWeb.UserSocket do
use Phoenix.Socket
def connect(%{"token" => token}, socket, _connect_info) do
IO.inspect "get here"
case Phoenix.Token.verify(socket, "user socket", token, max_age: 1209600) do
{:ok, user_id} ->
IO.inspect "and get there"
{:ok, assign(socket, :current_user, Syntax.Accounts.get_user!(user_id))}
{:error, reason} ->
IO.inspect "bad user socket token : #{reason}"
:error
end
end
end
The javascript code uses is :
let { Socket } = require('phoenix-channels');
socket = new Socket("ws:" + myurl + "/socket", {params: {token: userToken}})
socket.connect();
The request for connection reaches the server as I have both “get here” and “get there” displayed. Would anyone have an idea of what goes wrong ?
Trending in Questions
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
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
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
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
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Latest Phoenix Threads
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
sb8244
If you open your network tab and then refresh, you will see the 500 error request. There may be information as to why the error occurred here.
Another place to look for the error is the Phoenix logs. Can you paste what you see in red when the 500 occurs?
archimondain
Unfortunately there is nothing display on the server side : like everything is going fine.
I found out that the version of my code works with Phoenix version 1.4.0. The version I’m having problem with is 1.4.9. I’m thinking that maybe there is a compatibility issue with
phoenix-channels, or maybe the rest of my code is not compatible with version 1.4.9. On my EndPoint I haveMaybe it could help…
kokolegorille
Are You sure of this code? I use phoenix npm package… which is compatible with 1.4.9
BTW doing a DB query when using token is quite strange because You could get all needed info in the token. I sign my token like this.
So I don’t need to make additional DB query when checking token. It has the advantage to not expose sensitive data in socket assigns.
Unless You want to invalidate tokens, like guardian-db does.
archimondain
Thanks for the tip
I now have the exact same version of erlang/elixir/phoenix on dev and production, but I keep having the same issue on production while everything is fine on dev.
The only thing I can think of is the following: I use the following trick on production so that Cowboy can accept connections on the port 80 :
Is it possible that another program than
beam.smpis in charge of socket connections ?archimondain
I changed nothing, and at some point it started to work. This is mysterious…
Maybe some cache system somewhere caused this.
Addition :
I found something more specific : The problem disappear when I suppress the website cookie from my browser. I have to find out what causes this.
sb8244
Is it a particularly large cookie? A marketing installation caused this issue in my app once due to a shared domain. The solution in that case was to allow larger cookies to be processed by cowboy.
archimondain
I don’t think it was particularly large. I’ll check if the problem occurs again