Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocket: unable to handle malformed websocket data #146

Closed
michielpost opened this issue Jun 5, 2022 · 3 comments
Closed

WebSocket: unable to handle malformed websocket data #146

michielpost opened this issue Jun 5, 2022 · 3 comments

Comments

@michielpost
Copy link

michielpost commented Jun 5, 2022

Describe the bug
I'm trying to work with websocket data from bkex.com. I'm unable to handle their websocket response data with CryptoExchange.Net.

This is data that I am receiving:

42/quotation,["quotationOrderDepth",{"symbol":"BTC_USDT","ts":1654459536986,"asks":[["30094.52","1.16111"],["30096.94","0.51836"]],"bids":[["30094.20","1.48850"],["30093.98","0.89371"]]}]

It is being converted to a JToken, but fails and returns null:
https://github.com/JKorf/CryptoExchange.Net/blob/master/CryptoExchange.Net/Sockets/SocketConnection.cs#L449

It then goes into the backup flow, I assume to return it as a simple string.
https://github.com/JKorf/CryptoExchange.Net/blob/master/CryptoExchange.Net/Sockets/SocketConnection.cs#L450-L456

"42/quotation,["quotationOrderDepth",{"symbol":"BTC_USDT","ts":1654459536986,"asks":[["30094.52","1.16111"],["30096.94","0.51836"]],"bids":[["30094.20","1.48850"],["30093.98","0.89371"]]}]"

Tries to create a JToken of that:
tokenData = data.ToJToken(log);

That also fails with this error:
: 'Additional text encountered after finished reading JSON content: q. Path '', line 1, position 16.'

So the result is null and I'm unable to handle this message.

Any workaround for this? Or is it a bug that can be solved?

@JKorf
Copy link
Owner

JKorf commented Jul 31, 2022

I'd suggest to use the SetDataInterpreter method to set a string interpreter method which transforms the data into valid json which can then best processed

@github-actions
Copy link

No activity on this issue for 60 days. This issue will get closed if it receives no update within 14 more days.

@github-actions
Copy link

Closed for inactivity. Feel free to update this if the issue is still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants