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

Sanic v19.3 not support websockets v7.0. #1597

Closed
jaggerwang opened this issue May 28, 2019 · 6 comments
Closed

Sanic v19.3 not support websockets v7.0. #1597

jaggerwang opened this issue May 28, 2019 · 6 comments

Comments

@jaggerwang
Copy link

Sanic v19.3 required websockets version >=6.0 and <7.0. Is there any break change from v6.0 to v7.0? Websockets v6.0 not support to run as a module like python -m websockets wss://echo.websocket.org/.

@ahopkins
Copy link
Member

Yes, that is correct. Sanic requires websockets v6 right now because v7 introduced some breaking changes that have not yet been adopted.

See #1214 and #1233. There are probably some others too I am missing.

If you are at all interested in taking this on, I can help point you in the direction needed.


If you want to run websockets that way, then why do you need Sanic on top of it? Is there a particular feature you are looking for in v7? I also should mention that #1475 is nearing completion and should make it into Sanic 19.6, which will give the ability to run for an ASGI server (which includes websocket support without the websockets package).

@jaggerwang
Copy link
Author

Got it! Right now just because I want to use websockets module as a client to test, but I can install v7.0 outside of the venv.

@ahopkins
Copy link
Member

ahopkins commented May 28, 2019

👍 FWIW, I added an alias to my terminal to conveniently allow me to connect using the CLI utility regardless of what environment I am in.

$ ws ws://localhost/feed

Alias:

ws='/home/adam/.virtualenvs/websockets/bin/python -m websockets'

@Tronic
Copy link
Member

Tronic commented Jul 26, 2019

I tried current git master with websockets 8.0.1 and all tests pass OK. The requirement for websockets<7 is causing dependency issues, especially when multiple web frameworks are used in the same project. Issues #1214 and #1233 appear to be about new features. Is there still something that is actually broken by using the latest websockets version?

@ahopkins
Copy link
Member

@Tronic The last I had tested it, there were some breaking changes in names. And, in running examples/websocket.py, it looks like that is still the case.

[2019-08-11 10:34:43 +0300] [22005] [ERROR] Exception occurred while handling uri: 'ws://localhost:8000/feed'
Traceback (most recent call last):
  File "/home/adam/Projects/Sanic/sanic/sanic/app.py", line 944, in handle_request
    response = await response
  File "/home/adam/Projects/Sanic/sanic/sanic/app.py", line 491, in websocket_handler
    request, subprotocols
  File "/home/adam/Projects/Sanic/sanic/sanic/websocket.py", line 75, in websocket_handshake
    key = handshake.check_request(request.headers)
  File "/home/adam/.virtualenvs/sanic/lib/python3.7/site-packages/websockets/handshake.py", line 78, in check_request
    [parse_connection(value) for value in headers.get_all("Connection")], []
AttributeError: 'multidict._multidict.CIMultiDict' object has no attribute 'get_all'

@ahopkins
Copy link
Member

See #1635 for a fix.

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

3 participants