So I’d like to test building an app that can interact with websockets over the command line. I have been able to connect to a server using websocat websocat "ws://127.0.0.1:4000/socket/websocket?token=token&vsn=2.0.0"
. I even figured out how to join a topic by sending [null, null, "room:lobby", "phx_join", {}]
. However I don’t quite understand what the two null
values represent. When I try to send something as JSON, I get the following error:
[error] Ranch listener ChanWeb.Endpoint.HTTP had connection process started with :cowboy_clear:start_link/4 at #PID<0.479.0> exit with reason: {{:badmatch, "{\"event\":\"phx_join\",\"payload\":{},\"ref\":null,\"topic\":\"room:lobby\"}"}, [{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: 583]}, {Phoenix.Endpoint.Cowboy2Handler, :websocket_handle, 2, [file: 'lib/phoenix/endpoint/cowboy2_handler.ex', line: 120]}, {:cowboy_websocket, :handler_call, ...
How can I send a message that would be handled by a handle_info/2
callback? Where are these things documented?