altangent / ccxws

WebSocket client for 38 cryptocurrency exchanges
MIT License
619 stars 187 forks source link

[Bug]Bitmex Client cannot handle quote message because of undefined property #233

Open purplesmoke05 opened 3 years ago

purplesmoke05 commented 3 years ago

Hi. I love this repository and I found a bug. I got below error message...

https://github.com/altangent/ccxws/blob/c7908b43d55a82c76b4ae9c851c5b76a94352e0c/src/exchanges/bitmex-client.js#L436

| TypeError: Cannot read property 'symbol' of undefined
|     at BitmexClient._onQuoteMessage (/app/node_modules/ccxws/src/exchanges/bitmex-client.js:436:33)
|     at BitmexClient._onMessage (/app/node_modules/ccxws/src/exchanges/bitmex-client.js:123:12)
|     at SmartWss.<anonymous> (/app/node_modules/ccxws/src/basic-client.js:191:16)
|     at SmartWss.emit (events.js:310:20)
|     at WebSocket.<anonymous> (/app/node_modules/ccxws/src/smart-wss.js:78:43)
|     at WebSocket.emit (events.js:310:20)
|     at Receiver.receiverOnMessage (/app/node_modules/ws/lib/websocket.js:825:20)
|     at Receiver.emit (events.js:310:20)
|     at Receiver.dataMessage (/app/node_modules/ws/lib/receiver.js:437:14)
bmancini55 commented 3 years ago

Hi, thanks for submitting an issue! Can you provide the market you were subscribing to when this happened?

purplesmoke05 commented 3 years ago

I was subscribing random symbols so I debugged. And I found messages websocket received below. It seems that messages symbol contain "." character have no data field, so I do not have to subscribe these symbols...

'{"table":"quote","action":"partial","keys":[],"types":{"timestamp":"timestamp","symbol":"symbol","bidSize":"long","bidPrice":"float","askPrice":"float","askSize":"long"},"foreignKeys":{"symbol":"instrument"},"attributes":{"timestamp":"sorted","symbol":"grouped"},"filter":{"symbol":".BADAXBT"},"data":[]}'

'{"table":"quote","action":"partial","keys":[],"types":{"timestamp":"timestamp","symbol":"symbol","bidSize":"long","bidPrice":"float","askPrice":"float","askSize":"long"},"foreignKeys":{"symbol":"instrument"},"attributes":{"timestamp":"sorted","symbol":"grouped"},"filter":{"symbol":".BXRPXBT30M"},"data":[]}'

'{"table":"quote","action":"partial","keys":[],"types":{"timestamp":"timestamp","symbol":"symbol","bidSize":"long","bidPrice":"float","askPrice":"float","askSize":"long"},"foreignKeys":{"symbol":"instrument"},"attributes":{"timestamp":"sorted","symbol":"grouped"},"filter":{"symbol":".BXRPXBT_NEXT"},"data":[]}'

'{"table":"quote","action":"partial","keys":[],"types":{"timestamp":"timestamp","symbol":"symbol","bidSize":"long","bidPrice":"float","askPrice":"float","askSize":"long"},"foreignKeys":{"symbol":"instrument"},"attributes":{"timestamp":"sorted","symbol":"grouped"},"filter":{"symbol":".BETHXBT"},"data":[]}'

'{"table":"quote","action":"partial","keys":[],"types":{"timestamp":"timestamp","symbol":"symbol","bidSize":"long","bidPrice":"float","askPrice":"float","askSize":"long"},"foreignKeys":{"symbol":"instrument"},"attributes":{"timestamp":"sorted","symbol":"grouped"},"filter":{"symbol":".BADAT"},"data":[]}'

'{"table":"quote","action":"partial","keys":[],"types":{"timestamp":"timestamp","symbol":"symbol","bidSize":"long","bidPrice":"float","askPrice":"float","askSize":"long"},"foreignKeys":{"symbol":"instrument"},"attributes":{"timestamp":"sorted","symbol":"grouped"},"filter":{"symbol":".BXRP_NEXT"},"data":[]}'

'{"table":"quote","action":"partial","keys":[],"types":{"timestamp":"timestamp","symbol":"symbol","bidSize":"long","bidPrice":"float","askPrice":"float","askSize":"long"},"foreignKeys":{"symbol":"instrument"},"attributes":{"timestamp":"sorted","symbol":"grouped"},"filter":{"symbol":".XBT"},"data":[]}'