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

fix websockets in werkzeug 2x #724

Merged
merged 6 commits into from
Sep 20, 2021
Merged

Conversation

mattbennett
Copy link
Member

@mattbennett mattbennett commented Sep 19, 2021

Beginning with 2.0.0, Werkzeug started identifying incoming websocket requests, and only matching them to rules that are marked as being websocket targets. See pallets/werkzeug#2052.

This breaks Nameko's websocket functionality which defines some rules that were not marked as being websocket targets, which thus no longer match, resulting in a 400 error. With Werkzeug 2x it is sufficient to simply mark these rules as being websocket targets, but this results in a 400 error Werkzeug 1x for the same reason -- no rule matches the type of request framework determines the request to be.

This PR makes the explicit identification of a rule as a websocket target conditional on the version of Werkzeug. Furthermore, in Werkzeug < 1.0.0 the Rule constructor doesn't even accept the websocket argument, so this PR also drops support for those versions.

Alternatives to the approach taken here are:

  • Not supporting Werkzeug 2x
  • Only supporting Werkzeug 2x and dropping support for older versions
  • Forcing the auto-detection of websocket requests off (by passing websocket=False into adapter.match())

The conditional is the most explicit solution and is easily removed if we decide to drop support for Werkzeug 1.x in the future.

@mattbennett mattbennett marked this pull request as ready for review September 19, 2021 19:15
@mattbennett mattbennett changed the title pin down werkzeug <2 fix websockets in werkzeug 2x Sep 20, 2021
@mattbennett mattbennett merged commit e924281 into nameko:master Sep 20, 2021
@mattbennett mattbennett deleted the websocket-fix branch September 20, 2021 12:44
mattbennett added a commit to mattbennett/nameko that referenced this pull request Sep 20, 2021
* pin down werkzeug <2

* use a conditional fix for 2.x to be compatible

* require packaging lib

* import sort

* websocket argument was added in 1.0.0

* werkzeug 2.0.1 not published for py2
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

Successfully merging this pull request may close these issues.

None yet

1 participant