hunchensocket icon indicating copy to clipboard operation
hunchensocket copied to clipboard

pending opcode is not reset properly

Open rongarret opened this issue 7 years ago • 3 comments

The pending-opcode slot in a client is not reset properly after receiving a data message. The result is that whatever type of message (text or binary) is received first, all subsequent messages will be received as that same type regardless of their actual type.

rongarret avatar Mar 23 '17 18:03 rongarret

This seems to fix the problem:

diff --git a/hunchensocket.lisp b/hunchensocket.lisp
index df3797a..902f684 100644
--- a/hunchensocket.lisp
+++ b/hunchensocket.lisp
@@ -411,7 +411,7 @@ format control and arguments."
                       (t
                        (websocket-error
                         1002 "Client sent unknown opcode ~a" opcode))))
-              (setf pending-fragments nil))
+              (setf pending-fragments nil pending-opcode nil))
              ((eq +ping+ opcode)
               ;; Reply to client-initiated ping with a server-pong with the
               ;; same data

rongarret avatar Mar 23 '17 19:03 rongarret

This seems to make a lot of sense at first sight. Can you submit this as a pull request?

joaotavora avatar Mar 23 '17 23:03 joaotavora

Receiving binary messages fails anyway with "Binaries not accepted" error, if I remove the error in check-message it appears to work.

jurov avatar Jun 03 '20 15:06 jurov