Commits

Anonymous committed 6c4b77b

Bug fix: close the connection after a decoding error (and add the reason to the response)

Comments (0)

Files changed (1)

websocket_client.py

         try:
             self._state(data)
         except (DecodingError, FrameLengthExceeded), error:
-            self.protocol.close(error.status_code, "")
+            self.protocol.close(error.status_code, error.args[0])
+            self.closing = True
             return
 
         while self._consumed_all == 0 and not self.closing:
             try:
                 self._state(None)
             except (DecodingError, FrameLengthExceeded), error:
-                self.protocol.close(error.status_code, "")
+                self.protocol.close(error.status_code,  error.args[0])
                 break