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

Make websockets a bit nicer. #706

Closed

Conversation

mbirtwell
Copy link

I'd be interested to hear what you think of this. I was trying to get a pure python implementation of websockets working with Flask (no gevent, no uwsgi, no twisted, no autobahn) and I failed. But on the way I did get a version working with werkzeug and wsgiref (some monkeypatching of wsgiref required). There was however an ugly in the result with werkzeug. This pull request fixes that. In case anyone is interested my websocket implementation is at https://github.com/mbirtwell/simple-websockets and at the time very incomplete.

To create a websocket it is necessary to set the connection and upgrade
headers and not set the content-length header. At the moment werkzeug
will set a second connection header for close in this situation, this as it
happens doesn't seem to bother the couple of browser I've tried this with
(Chrome and IE) but it's not pretty.

To create a websocket it is necessary to set the connection and upgrade
headers and not set the content-length header. At the moment werkzeug
will set a second connection header for close in this situation, this as it
happens doesn't seem to bother the couple of browser I've tried this with
(Chrome and IE) but it's not pretty.
@RonnyPfannschmidt
Copy link
Contributor

its likely problematic to put websockets into the builtin webserver like this,
its mainly a very minimal server implementation for debugging and local dev
and this change is just a minimal untested ad-hoc change to get "something working somehow"

while i'm pretty sure this works instinct tells me there is a problem hiding

with my current knowledge i strongly suggest to use either external web-socket integration's
or a fully blown integration that properly handles concurrency and process state

i will take a look at your lib later today to make suggestions wrt steps to make your integration viable
and make an attempt to see whats missing to make it work with flask

@ghost
Copy link

ghost commented Jan 19, 2018

Correct me if I'm wrong, but I spied a websocket.py module in my Werkzeug when I updated to 14.1 but I don't see it in the docs or anywhere else. Anyone know what might be going on there?

@davidism
Copy link
Member

Closing due to age, and I'm not clear that this change is correct. I'd rather focus on ASGI for async applications.

@davidism davidism closed this May 22, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
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 this pull request may close these issues.

3 participants