Yes, the error is coming from wscat. I tried again while timing it with a stopwatch but it keeps generating the same error in less than 40 secs. I have my terminal split to two: one running $ iex -S mix phx.server
and the other running wscat
. The terminal running phoenix is all in red when the wscat
returns the Disconnected (code: 1011, reason: "")
error.
Here is the error message from the phoenix server:
[error] GenServer #PID<0.431.0> terminating
** (Jason.DecodeError) unexpected byte at position 0: 0x48 ('H')
(jason 1.2.0) lib/jason.ex:78: Jason.decode!/2
(phoenix 1.4.16) lib/phoenix/socket/serializers/v2_json_serializer.ex:30: Phoenix.Socket.V2.JSONSerializer.decode!/2
(phoenix 1.4.16) lib/phoenix/socket.ex:564: Phoenix.Socket.__in__/2
(phoenix 1.4.16) lib/phoenix/endpoint/cowboy2_handler.ex:120: Phoenix.Endpoint.Cowboy2Handler.websocket_handle/2
(cowboy 2.7.0) /home/uzisky/_phx/hello_sockets/deps/cowboy/src/cowboy_websocket.erl:482: :cowboy_websocket.handler_call/6
(cowboy 2.7.0) /home/uzisky/_phx/hello_sockets/deps/cowboy/src/cowboy_http.erl:231: :cowboy_http.loop/1
(stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: {:DOWN, #Reference<0.589201659.3935567875.121381>, :process, #PID<0.428.0>, {%Jason.DecodeError{data: "HelloSocketsWeb.Endpoint.broadcast(\"ping\", \"test\", %{data: \"test\"})", position: 0, token: nil}, [{Jason, :decode!, 2, [file: 'lib/jason.ex', line: 78]}, {Phoenix.Socket.V2.JSONSerializer, :decode!, 2, [file: 'lib/phoenix/socket/serializers/v2_json_serializer.ex', line: 30]}, {Phoenix.Socket, :__in__, 2, [file: 'lib/phoenix/socket.ex', line: 564]}, {Phoenix.Endpoint.Cowboy2Handler, :websocket_handle, 2, [file: 'lib/phoenix/endpoint/cowboy2_handler.ex', line: 120]}, {:cowboy_websocket, :handler_call, 6, [file: '/home/uzisky/_phx/hello_sockets/deps/cowboy/src/cowboy_websocket.erl', line: 482]}, {:cowboy_http, :loop, 1, [file: '/home/uzisky/_phx/hello_sockets/deps/cowboy/src/cowboy_http.erl', line: 231]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 249]}]}}
State: %Phoenix.Socket{assigns: %{}, channel: HelloSocketsWeb.PingChannel, channel_pid: #PID<0.431.0>, endpoint: HelloSocketsWeb.Endpoint, handler: HelloSocketsWeb.UserSocket, id: nil, join_ref: "1", joined: true, private: %{log_handle_in: :debug, log_join: :info}, pubsub_server: HelloSockets.PubSub, ref: nil, serializer: Phoenix.Socket.V2.JSONSerializer, topic: "ping", transport: :websocket, transport_pid: #PID<0.428.0>}
[error] Ranch listener HelloSocketsWeb.Endpoint.HTTP had connection process started with :cowboy_clear:start_link/4 at #PID<0.428.0> exit with reason: {%Jason.DecodeError{data: "HelloSocketsWeb.Endpoint.broadcast(\"ping\", \"test\", %{data: \"test\"})", position: 0, token: nil}, [{Jason, :decode!, 2, [file: 'lib/jason.ex', line: 78]}, {Phoenix.Socket.V2.JSONSerializer, :decode!, 2, [file: 'lib/phoenix/socket/serializers/v2_json_serializer.ex', line: 30]}, {Phoenix.Socket, :__in__, 2, [file: 'lib/phoenix/socket.ex', line: 564]}, {Phoenix.Endpoint.Cowboy2Handler, :websocket_handle, 2, [file: 'lib/phoenix/endpoint/cowboy2_handler.ex', line: 120]}, {:cowboy_websocket, :handler_call, 6, [file: '/home/uzisky/_phx/hello_sockets/deps/cowboy/src/cowboy_websocket.erl', line: 482]}, {:cowboy_http, :loop, 1, [file: '/home/uzisky/_phx/hello_sockets/deps/cowboy/src/cowboy_http.erl', line: 231]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 249]}]}