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
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
Hi,
we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley:
Mutonex gamedesign was finish...
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
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
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
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 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