Lawouach / WebSocket-for-Python

WebSocket client and server library for Python 2 and 3 as well as PyPy (ws4py 0.5.1)
https://ws4py.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
1.12k stars 288 forks source link

Frame parsing only returning first array and discarding the rest of socket message #240

Open GerardBCN opened 6 years ago

GerardBCN commented 6 years ago

Hi, I have a problem parsing the messages that the websocket of Bitfinex API sends (wss://api.bitfinex.com/ws/2) after connecting to it and sending the following payload

{
              "event": "subscribe",
              "channel": "book",
              "pair": "tBTCUSD",
              "prec": "R0"
            }

An example of a complete byte string returned by the websocket is the following:

b'\x81\x16[210,[7793198037,0,1]]\x81\x17[210,[7813472121,0,-1]]\x81\x17[210,[7813464771,0,-1]]\x81\x17[210,[7813472713,0,-1]]\x81"[210,[7813472969,8850,0.86764592]]\x81%[210,[7813472987,8850.1,-0.18178494]]\x81%[210,[7813473056,8850.1,-0.30526279]]\x81 [210,[7813473029,8851,-0.06004]]'

However, the parsing process happening in Frame class, is only returning the first array:

[210,[7793198037,0,1]]

and is discarding all the rest of the data.

Am I doing something wrong? should I set some special configuration? Is the protocol implemented in the Frame Class incomplete to handle multiple data objects in the response?

Using public websocket services such as https://websocket.org/echo.html I get all the arrays back, which makes be suspicious about ws4py...