Open bitnosis opened 3 years ago
Need to fix a couple strings in the code & library to make it work
flask_sockets.py [library]
def add_url_rule(self, rule, _, f, **options):
self.url_map.add(Rule(rule, endpoint=f, **options))
#: self.url_map.add(Rule(rule, endpoint=f))
rest_server.py [app itself]
#: @sockets.route(API.API_PREFIX + API.MARKET_DATA)
@sockets.route(API.API_PREFIX + API.MARKET_DATA, websocket=True)
def market_data(ws):
ws_data_request(ws, SubscriptionDataType.MARKET_DATA)
@sockets.route(API.API_PREFIX + API.MARKET_DEPTH, websocket=True)
Detailed explanation here:
https://github.com/heroku-python/flask-sockets/pull/82
WS client for the testing:
https://github.com/WangFenjin/Simple-WebSocket-Client
PS At least, I can send something to Sierra's server via WS, but I'm NOT [yet] getting a market data in the LOG section below [like shown on the video], but it could be due to
1. my Sierra server misconfiguration, OR
2. Certain CME restrictions for the live data
Sierra's server settings attached
![scr=SierraServerSettings](https://github.com/jseparovic/python-ws-dtc-client/assets/159127744/f8a26c97-6264-417a-bd15-097567f4b2ed)
PS downgrading flask didn't help; current versions [as of Feb 2024 - should be latest]:
`Flask Version: 3.0.2
Flask-Sockets Version: 0.2.1
websocket_client Version: 1.7.0
gevent-websocket Version: 0.10.1
...`
I get this error when trying to connect to the websockets..
handler, values = adapter.match() raise WebsocketMismatch() werkzeug.routing.WebsocketMismatch: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand. 2021-11-29T06:06:43Z {'REMOTE_ADDR': '127.0.0.1', 'REMOTE_PORT': '58134', 'HTTP_HOST': 'localhost:8022', (hidden keys: 30)} failed with WebsocketMismatch
Im trying to connect to the websockets like so
let socket = new WebSocket('ws://localhost:8022/api/v1/marketdata');
and my setup originally is...
example_client.py --host 127.0.0.1 --port 11099 -q 11098 -r 8022 -s