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 issue? #2

Open
bitnosis opened this issue Nov 29, 2021 · 1 comment
Open

Websocket issue? #2

bitnosis opened this issue Nov 29, 2021 · 1 comment

Comments

@bitnosis
Copy link

bitnosis commented Nov 29, 2021

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

@3orin
Copy link

3orin commented Feb 6, 2024

Need to fix a couple strings in the code & library to make it work

  1. 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))
  1. 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)
@sockets.route(API.API_PREFIX + API.MARKET_DEPTH, websocket=True)

Detailed explanation here:
heroku-python/flask-sockets#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

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

...`

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

No branches or pull requests

2 participants