Falcon: ASGI+WebSocket

Created on 2 Oct 2014  路  28Comments  路  Source: falconry/falcon

Is there a way to support websocket on falcon?

enhancement

Most helpful comment

Just a quick update on this, a generous community member has offered to sponsor the ASGI HTTP and WebSocket work. Either myself or one of the other core maintainers will work on the implementation for Falcon 2.0.

All 28 comments

It would be nice to be able to do that, but the WSGI spec forbids the use of so-called "hop-by-hop" headers, such as the Upgrade header used by WebSocket.

Instead, I would recommend configuring your web server or load balancer to proxy WebSocket handshake requests to a standalone server (or servers) running Autobahn or similar. Alternatively, uWSGI supports WebSocket natively and provides a Python library for bulding apps.

I would also like to see something like FlaskWebsockets for falcon ...

We've been toying with the idea of expanding the framework to support interfaces other than WSGI, such as twisted.web and aiohttp. If we start going down that path, WebSocket support in Falcon may make sense after all.

just as info, it seems django going to solve wsgi related problems this way: http://channels.readthedocs.org/en/latest/asgi.html

Related: #582

Any progress?

I'm interested in using Websockets with Falcon as well.

+1 For any type of websocket functionality. Would be great if we could find something workable.

Definitely. I have a use case for websockets + falcon I'd implement if support was there. I haven't gone the node route as I don't want to maintain two codebases for the same project.

Hi everyone, I've started work on #1055 and so far uvicorn looks like a very promising (no pun intended!) avenue for adding WebSocket support to Falcon. I'd like to gather a few concrete use cases to help inform the design. If you can, please provide an overview of how you are using--or plan to use--WebSocket connections, including subprotocols (either IANA-registered or bespoke). Thanks!

@kgriffs,

Awesome -- thanks! Quick question for you. I understand from earlier in the conversation that you said Websockets uses the upgrade header in order for it to work correctly. My question is whether SSE (Server Side Events) support within Falcon is doable currently? My understanding is that SSE is more of a one-way channel from the server to the browser.

Does Falcon currently support SSE and if not, would implementing Websockets also implement SSE support?

Thanks again!

@pushshift The WSGI spec isn't really designed for things like SSE, but it should be possible with uvicorn/ASGI (see also: http://www.uvicorn.org/#streaming-responses). This would probably be an extension of #1055 since it is based on regular HTTP vs. WebSocket.

(We'll probably want to label this as "experimental" in the first iteration since there will likely be feedback and perhaps immature dependencies.)

Hey, hi!

Any progress in this topic?

Falcon rocks! ... It would be great to have WebSocket support.

any update for web socket implementation in Falcon.

Any update on this?

After meeting with Amber (daphne/twisted) at PyCon I'm going to move forward with ASGI. Based on Andrew's talk, it seems that the spec has settled down and this is the best way forward without inventing yet another one-off async web stack (hooray!).

My current thinking is to add at least basic routing support so you can register a websocket handler for specific URLs that will be fed events with the connection scope (URL, template params, headers, etc.).

I plan to work on HTTP support first, and so WebSocket support may have to wait until 2.1 (TBD). If anyone would like to sponsor this feature for 2.0, I could certainly dedicate more time to it. http://falconframework.org/#sectionSupportFalconDevelopment

Hi @kgriffs what are your thoughts on how https://github.com/jgelens/gevent-websocket does it as well as flask's integration? I might be wrong but I think the implementation described in this ticket is Python 3 only.

@jrgp That interface looks similar to what we were thinking for Falcon. To keep things lean-and-mean, we likely won't implement any subprotocols out of the box, but we should ensure that it is straightforward to implement plug-ins/add-ons in that vein.

Just a quick update on this, a generous community member has offered to sponsor the ASGI HTTP and WebSocket work. Either myself or one of the other core maintainers will work on the implementation for Falcon 2.0.

@kgriffs, can you please let me know what is the tentative date for version 2.0 release? My project also requires web socket support in Falcon API.

Hi, sorry for the confusion. Since I made that last comment, we decided to ship 2.0 first (RC1 is currently available on PyPI) so that we could drop Python 2.7 and 3.4 support in 3.0 and do a cleaner ASGI implementation.

3.0 development just opened on the master branch and we anticipate this milestone cycle to be significantly shorter than 2.0, with the primary focus being on ASGI and improved form data parsing. We'll be sprinting on the 3.0 milestone at PyCon US so stay tuned!

You can see what is currently planned here: https://github.com/falconry/falcon/milestone/33

Just a quick update on this, we are hoping to get it into 3.0 if we have time, but if not it will be a fast-follow feature in 3.1. Regardless, 3.0 will support server-sent events (SSE) when using the new ASGI interface, as an alternative to sending events via WebSocket (which does not work for HTTP/2).

The plan is to add support via ASGI for sure, and possibly also via uWSGI's native WebSocket support.

Hey, just curious if there has been any update here?

Hey, just curious if there has been any update here?

They have been keeping us pretty up to date here: https://gist.github.com/kgriffs/a719c84aa33069d8dcf98b925135da39

UPDATE: I have completed an alpha-quality implementation in my fork. Hoping to get it into 3.0.0a2. Docs and full test coverage will then be the focus for getting WebSocket scope support ready for 3.0.0b1.

Wow! Really ?? ... I was waiting for this!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

codenoid picture codenoid  路  4Comments

kgriffs picture kgriffs  路  6Comments

neilalbrock picture neilalbrock  路  5Comments

yosiyuki picture yosiyuki  路  8Comments

coffeedoughnuts picture coffeedoughnuts  路  8Comments