-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No function clause error for some invocations of Mint.WebSocket.Frame.translate/1 #32
Comments
What is the backtrace for the function clause error you see? Also, if the data isn't sensitive, could you attach a packet capture using something like wireshark for a session that causes this?
Once |
Thanks for the quick reply and added detail. That helps my understanding a bit - I'll spend some more time tracing this to see if I can figure out why this is happening. Here's the stack trace: Elixir.FunctionClauseError no function clause matches
lib/mint/web_socket/frame.ex:380 Mint.WebSocket.Frame.translate({:continuation, <<0::size(3)>>, nil, "[data here]" <> ..., true})
lib/mint/web_socket/frame.ex:216 anonymous fn/2 in Mint.WebSocket.Frame.decode/2
lib/enum.ex:2468 Enum."-reduce/3-lists^foldl/2-0-"/3
lib/mint/web_socket/frame.ex:209 Mint.WebSocket.Frame.decode/2
lib/connector.ex:166 Watchtower.Connector.handle_responses/2
lib/connector.ex:121 Watchtower.Connector.handle_info/2
gen_server.erl:1123 :gen_server.try_dispatch/4
gen_server.erl:1200 :gen_server.handle_msg/6 I'll see if I can get the raw packets. Unfortunately, this happens intermittently in production, and since there's about 1-5 Mb/s of traffic being processed it may not be trivial to capture the problem sequence. |
Even if this behavior is unexpected, raising a function clause error is really not ideal. We could add a clause to One other thing to look for: in the code that calls |
Yeah I agree - at least with an error tuple the developer can catch flaky websocket servers (which is what it appears like in my case). The problem server hasn't sent junk packets for over a week now, so although I won't be able to test this in production at the moment, I've included a test case with the patch that should cover the event above. |
I've been running across a no function clause error in
lib/mint/web_socket/frame.ex:380
forMint.WebSocket.Frame.translate/1
when connecting to some 3rd party services.The triggering call is the following:
It looks like an opcode
<<0::size(3)>>
is negatively matched against (below), but there are no other translate/1 functions to match<<0::size(3)>>
in a continuation.mint_web_socket/lib/mint/web_socket/frame.ex
Line 381 in 7e29878
Meanwhile, the spec (https://www.rfc-editor.org/rfc/rfc6455) Section 5.2 seems to only define opcode of size(4), which is successfully matched from
@opcodes
for all other requests.mint_web_socket/lib/mint/web_socket/frame.ex
Line 77 in 7e29878
I'm happy to submit a patch, but I'm not that familiar with the protocol to know the alternative. I'm assuming there's a good reason why the negative against
<<0::size(3)>>
is in place?The text was updated successfully, but these errors were encountered: