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 routing and handling #2052

Closed
miguelgrinberg opened this issue Feb 28, 2021 · 0 comments · Fixed by #2053
Closed

WebSocket routing and handling #2052

miguelgrinberg opened this issue Feb 28, 2021 · 0 comments · Fixed by #2053
Milestone

Comments

@miguelgrinberg
Copy link
Contributor

miguelgrinberg commented Feb 28, 2021

While there's been some effort in adding websocket routing support, there are still a couple of things that are missing:

  • When the server receives a ws:// or wss:// request, it still creates a MapAdapter() instance that is configured to handle HTTP, so the only way to match a WebSocket route is to manually pass websocket=True in the match() call. If the incoming request has the Connection: Upgrade and Upgrade: WebSocket headers in it, then it is a WebSocket request, so the MapAdapter should be initialized to match WebSocket by default.
  • To be able to implement WebSocket, the route handler function needs to take control of the underlying socket, so that it can do the WebSocket handshake, send the 101 response and then start sending/receiving WebSocket frames. Gunicorn handles this by adding the gunicorn.socket key to the environ dictionary. Werkzeug could add a werkzeug.socket key to expose its socket.

Adding solutions to the above problems would allow a Werkzeug or Flask application to implement a WebSocket route, for example using wsproto.

@miguelgrinberg miguelgrinberg mentioned this issue Feb 28, 2021
6 tasks
@davidism davidism added this to the 2.0.0 milestone Mar 3, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants