-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Compatibility with WsgiToAsgi
middleware
#58
Comments
WsgiToAsgi
middleware
The WSGI protocol does not support WebSocket. Flask-Sock implements a number of non-standard WSGI extensions used by Gunicorn, Werkzeug, Eventlet and Gevent that allow WebSocket to work in spite of WSGI not supporting it. You will need to extend WsgiToAsgi so that the WSGI context that is passed to Flask and Flask-Sock uses one of the supported server extensions to WSGI. Like for example, you can add the |
Would it be reasonable (and/or technologically possible) for |
I'm not sure, to be honest. I think this would make more sense to support (maybe optionally) on the asgiref project, but I'm not sure how they'll feel about it, given that all the ways to pass on a socket to a WSGI app are non-standard. Without having context for your project, to me it feels strange that you are working with Flask and Flask-Sock but you are using an ASGI web server. Why not use FastAPI or Quart instead, which have native ASGI support for WS? |
ReactPy supports several different web frameworks: Running with an ASGI webserver isn't mandatory here, but it would be "nice to have". Knowing the Django team, it's very unlikely they'd be willing to accept non-standard extensions within the |
How about your project including a wrapper to WsgiToAsgi that adds the socket to |
Definitely possible, but at that point it feels more appropriate to contribute that wrapper to this repo. I'm sure some other Flask enthusiasts would enjoy using that. |
To be honest, adding such feature here would give the wrong message. People may think that this is a supported and approved way to run this extension, while in fact it is a very bad idea, and may put additional support effort on my part in the future, if things were to break. Let's not forget that what I'm describing here as a solution is a hack. You would be impersonating Gunicorn or any of the other web servers I support. I would be open to add support for the |
I'm realizing now that This sounds like a bottomless rabbit hole, which isn't really worth it for a non-critical feature on our repo. |
asgiref.sync.WsgiToAsgi
does not work withflask-sock
due to several factorsThe main issue appears to be that
WsgiToAsgi
assumes that WSGI apps are only capable ofscope["type"] == "http"
.I attempted to remove all the
WsgiToAsgi
restrictions but it resulted in both broken HTTP and Websockets. There might need to be some collaborative PRs between this repo anddjango/asgiref
in order to get this working.Sync Websockets are possible within ASGI as proven by
django/channels
. Which means thatWsgiToAsgi
middleware should, in theory, be able to support this.The text was updated successfully, but these errors were encountered: