spell
spell copied to clipboard
websocket and ping messages
Thanks for the awesome lib!
I think I found a small bug, in transport/websocket.ex, there is
def websocket_handle({frame_type, raw_message}, _conn_state, state)
when frame_type in [:text, :binary] do
but it seems that frame_type may also be :ping, with raw_message being a few random bytes, and I guess we then should respond with :pong and those few random bytes. Currently websocket_handle function clause for ping frame_type seems to be missing. I'm just learning elixir and it seems that my elixir-fu is not yet good enough to fix it.
e.g. msg: {:ping, "cLyY"}
It's true. Here is a message for this
16:53:31.870 [error] ** Websocket client Spell.Transport.WebSocket terminating in :websocket_handle/3
for the reason :error::function_clause
** Handler state was %{owner: #PID<0.158.0>, serializer_info: %{frame_type: :text, name: "json"}}
** Stacktrace: [{Spell.Transport.WebSocket, :websocket_handle,
[{:ping, "GX7q"},
{:websocket_req, :wss, 'api.poloniex.com', 443, '/', :infinity, :undefined,
{:sslsocket, {:gen_tcp, #Port<0.5244>, :tls_connection, :undefined},
#PID<0.163.0>}, :ssl, Spell.Transport.WebSocket,
"8sfuVDN7d5LCQ4ELPtVcnQ==", :undefined, 1, :undefined, :undefined,
:undefined},
%{owner: #PID<0.158.0>,
serializer_info: %{frame_type: :text, name: "json"}}],
[file: 'lib/spell/transport/websocket.ex', line: 64]},
{:websocket_client, :retrieve_frame, 6,
[file: 'src/websocket_client.erl', line: 378]},
{:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}]
Looking forward to get a quick turn about this.
Thanks.
fixed
@Zatvobor Can you submit a PR?