Skip to content
This repository has been archived by the owner on Jan 20, 2023. It is now read-only.

websocket and ping messages #48

Open
comboy opened this issue Apr 25, 2016 · 3 comments
Open

websocket and ping messages #48

comboy opened this issue Apr 25, 2016 · 3 comments

Comments

@comboy
Copy link

comboy commented Apr 25, 2016

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"}

@Zatvobor
Copy link

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.

Zatvobor added a commit to Zatvobor/spell that referenced this issue Jul 17, 2016
@Zatvobor
Copy link

fixed

@andykingking
Copy link

@Zatvobor Can you submit a PR?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants