tenzil
Socket reconnecting again and again without token after successful connection
Hi guys,
Well i face this, dont know whether its an actual issue or not. Please explain this.
Initially the socket gets connected with the token passed, using that socket i have initialised UserChat. Now suddenly after few functionalities, sockets are refused connection.
They get connected and trying to reconnect again without token and got refused. What is going on. Please explain this.
[info] CONNECTED TO MyApp.UserSocket in 325µs
Transport: :websocket
Serializer: Phoenix.Socket.V2.JSONSerializer
Connect Info: %{}
Parameters: %{"token" => "SFMyNTY.g3QAAAACZAAEZGF0YWEBZAAGc2lnbmVkbgYALIZirm8B.bf7HXYzDMLRtWboqTxu5ewhrNFrT9loL2YHkuREm-zU", "vsn" => "2.0.0"}
[info] CONNECTED TO Phoenix.LiveView.Socket in 255µs
Transport: :websocket
Serializer: Phoenix.Socket.V2.JSONSerializer
Connect Info: %{session: nil}
Parameters: %{"vsn" => "2.0.0"}
:invalid
[info] REFUSED CONNECTION TO MyApp.UserSocket in 266µs => Getting refused again and again,
Transport: :websocket
Serializer: Phoenix.Socket.V2.JSONSerializer
Connect Info: %{}
Parameters: %{"token" => "", "vsn" => "2.0.0"}
:invalid => reponse from below method
def connect(%{"token" => token}, socket, _connect_info) do
case Phoenix.Token.verify(socket, "user socket", token, max_age: 1209600) do
{:ok, user_id} ->
{:ok, assign(socket, :current_user, user_id)}
{:error, reason} ->
IO.inspect reason
:error
end
end
How to resolve this “refused connection”,
[info] REFUSED CONNECTION TO MyApp.UserSocket in 266µs =>
Getting refused again and again,
socket.js
import {Socket} from "phoenix"
let socket = new Socket("/socket", {params: {token: window.userToken}})
socket.connect()
export default socket
i followed Multiple Room Chat Application - ElixirCasts
app.js
import socket from "./socket"
import liveSocket from "./live_socket"
import UserChat from "./user_chat"
UserChat.init(socket)
It will be very helpful if someone explains this. Thanks again
Popular in Discussions
I’d love to hear what people think about Wisp, the new Gleam web framework started by Gleam’s primary creator Louis Pilfold.
Gleam, alon...
New
I wanted to capitalize a string, and tried using String.capitalize().
That generally works well, until you try to capitalize a word like...
New
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New
Hi there Elixir friends :vulcan_salute:
In a recent task I was on, I needed to check in two dates which of them is the maximum and which...
New
I’ve just started the Phoenix part of the utterly brilliant online course by @pragdave. On generating the Phoenix app he uses the --no-ec...
New
Just a little information upfront. Generally speaking, if I feel like I need to either break a pipe chain or use an anonymous function in...
New
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition)
It’s been a while since we first asked this, I...
New
Are there any downsides, like perf issues, to putting all functional components in CoreComponents as long as you prefix it with the conte...
New
Hi all
How can I compare haskell with elixir, included tools, webservices, ect.
Thanks
New
I like Umbrella projects and pretty much always use them for personal Elixir stuff, especially Nerves things.
But I don’t think this is ...
New
Other popular topics
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
15:22:35.803 [error] gen_event {lager_file_backend...
New
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help.
Where are they similar?
Where do they differ the m...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
Hello, how can I check the Phoenix version ?
Thanks !
New
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
New
Hello everybody,
usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
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
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









