Bittrex websockets encoding method?

微笑、不失礼 提交于 2020-01-25 07:25:13

问题


It´s not a big deal to mimic the websocket connection made to bittrex from www, using chromes dev tools:

GET https://socket.bittrex.com/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22c2%22%7D%5D&_=1524596108843

This return a token

"ConnectionToken":"gbLsm8C6Jck1mQTTFjmuIv5qgUuMZz/kXU1s+fAnjnW
qUFQocNBfp3VOrd/y0acxWL5Fv7MZ54heRddLYZS+EMhLnaPPQiSZblvgJPCbLKqZTIkb"

That needs to be used with:

wss://socket.bittrex.com/signalr/connect? 
transport=webSockets&clientProtocol=1.5&connectionToken=

Then there are some commands sent to the websocket:

{"H":"c2","M":"SubscribeToSummaryLiteDeltas","A":[],"I":0}
{"H":"c2","M":"SubscribeToExchangeDeltas","A":["BTC-TRX"],"I":1}
{"H":"c2","M":"QueryExchangeState","A":["BTC-TRX"],"I":2}

Which makes bittrex stream data about the selected ticker, BTC-TRX. But here´s where things start to get odd:

Here´s what frames look like:

    {"C":"d-C95D047D-E,0|OHjr,0|OHjs,2|CW,6116","M":[{"H":"C2","M":"uE","A":["dY+7DsIwDEX/xXOI7NiOnYwwg0TpwENd+QnUfydtBQKp9ear4yPfFxyhwr4/7PruCgFOUJO4SoA71McL+lsLAnRQMeI0xhzg3EKXQpEFzUvyMayhiWaUOJtqLCZKonkcAly+cvyXl/lCHKOyaxbDdbUuamMXzhELk5lvvKE+s0yoyWPKVIhwg81LO8OcNCZOGQn5g9IPSuyLtq1To2drNIxv"]}]}

It certainly looks like base64, but decoding it gives me something like:

u���0E��s��؎��0�D��C]� �'m����#��¾?��� NP��J�;���[tP1�4���B�B��K�1���f�8�j,&J�y\�r����B��k�u�.jc���o��>�L��c�T�p��K;Ü4&N ���J싶�S�gk4�o

Did anyone figure out how to turn this into readable data?


回答1:


The response appears to be (at least in a Python world) subject to b64decode() and decompress().

message = decompress(b64decode(message))


来源:https://stackoverflow.com/questions/50011256/bittrex-websockets-encoding-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!