Skip to content

ws.readData() unable to handle a null result #71

@jfilby

Description

@jfilby

When I receive data from the websocket that has a null result, the program crashes.

In the attached test case, if you comment out the line that sends the subscribe request the program doesn't crash. This is because the message that is sent back includes a null result. However the websocket library should be able to handle this.

Here's the output from a Chrome websocket extension that does the same thing. The result from the subscribe request is null, but the websocket loop continues to function as expected.

{"e":"kline","E":1660633181407,"s":"BNBUSDT","k":{"t":1660633140000,"T":1660633199999,"s":"BNBUSDT","i":"1m","f":578704188,"L":578704249,"o":"317.00000000","c":"316.90000000","h":"317.10000000","l":"316.80000000","v":"111.62500000","n":62,"x":false,"q":"35378.63340000","V":"12.78200000","Q":"4052.67600000","B":"0"}}
{"e":"kline","E":1660633188428,"s":"BNBUSDT","k":{"t":1660633140000,"T":1660633199999,"s":"BNBUSDT","i":"1m","f":578704188,"L":578704250,"o":"317.00000000","c":"316.90000000","h":"317.10000000","l":"316.80000000","v":"111.65900000","n":63,"x":false,"q":"35389.40800000","V":"12.81600000","Q":"4063.45060000","B":"0"}}
{  "method": "SUBSCRIBE",  "params": [    "adausdt@kline_1m"  ],  "id": 1 }
{"result":null,"id":1}
{"e":"kline","E":1660633189014,"s":"ADAUSDT","k":{"t":1660633140000,"T":1660633199999,"s":"ADAUSDT","i":"1m","f":403020801,"L":403020878,"o":"0.55370000","c":"0.55320000","h":"0.55370000","l":"0.55310000","v":"39277.50000000","n":78,"x":false,"q":"21734.35789000","V":"14835.80000000","Q":"8208.74871000","B":"0"}}
{"e":"kline","E":1660633190748,"s":"BNBUSDT","k":{"t":1660633140000,"T":1660633199999,"s":"BNBUSDT","i":"1m","f":578704188,"L":578704251,"o":"317.00000000","c":"316.80000000","h":"317.10000000","l":"316.80000000","v":"111.75900000","n":64,"x":false,"q":"35421.08800000","V":"12.81600000","Q":"4063.45060000","B":"0"}}

test_ws.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions