Allow to accept websocket extensions
Also accept permessage-deflate, permessage-bzip2 and permessage-snappy
compression extensions by default if client requests for them.
Compression/decompression of the messages is taken care of by autobahn
package.
Fixes #326
Hey @carltongibson, could you please take a look at this PR. I could update it as needed.
Hi @albertas Thanks for this. I'm going to focus on the Channels release and then I'll cut back to do a release here!
Hi @carltongibson, could I get an update/feedback for this PR? I see that Daphne v3 was already released. Is there any chance for releasing this PR in near future?
If I'm understanding correctly, Daphne doesn't support websocket extensions as-is and this PR would add support for that?
@benrudolph If you wanted to pick this up and rebase it, I'd be happy to have a look.
alrighty, i'll take a look
Well, merge conflicts were trivial: only for added imports. I have solved them using web editor in no time. Looking forward for your reviews.
So @benrudolph — does this allow you to do what you're after?
thanks, yes. i realize that this just enables adding extension headers to support compression, not compression itself, but this does help. channels doesn't really provide the capability to compress out of the box, but it's certainly a no-go if daphne ignores the headers. in any case, yes, this is great, thanks!
Ok, thanks for the feedback @benrudolph. If you want to discuss what else you'd need in a Discussion on Channels that would be good, but we'll look to get this in here in the meantime.
Thanks appreciate it
@benrudolph Well, Daphne uses Autobahn package underneath, which has implementation for various compressions. This PR both enables to accept any kind of headers and enables permessage-deflate, permessage-bzip2 and permessage-snappy compressions. permessage-deflate compression should be fully working with this PR, but it still needs testing in real environment.
oh amazing! 🔥 🔥 that's a huge win
@carltongibson anything we can do to get this puppy in?
@benrudolph Not really. You could install it with pip, test it, report back.
On schedule: We had a channel_redis release this week. Next up is Channels itself. Then I will look back to Daphne. Sorry if that's slow for you, but it's just me so it sometimes takes a while. 🙂
sounds good. wow! you're maintaining those 3 libraries solo?? that's simultaneously incredible and a little terrifying 👏
It’s mostly terrifying. 😃 (folks do help, but input welcome!)
bump
@carltongibson How could I help to push this one out? I will test this PR by writing simple django project example with permessage-deflate compression enabled. I could also update/add channels documentation. Also I could add additional tests. Just let me know whats needed.
Hi @albertas — Yes... — my issue is in getting to it. I'm pretty sure it's correct, but I need to review, and that involves digging into the spec and the underlying Autobahn implementation, and I just haven't got to that yet.
I guess a couple of choice links here pointing me where to look would speed that up. (Silly as that sounds...)
Then, do we need any additions to the README here?
@albertas — Just to say more positively, it's been summer, but let's get a release done in September, with this in it.
(By any I mean some — if I'm a user, what helps me leverage this? — Probably those links... 🤔)
Thanks!
@carltongibson here are several links I found:
- WebSocket protocol specification: https://tools.ietf.org/doc/html/rfc6455
- permessage-deflate specification: http://tools.ietf.org/html/draft-ietf-hybi-permessage-compression
- Autobahn docs about permessage compression: https://github.com/crossbario/autobahn-python/blob/fd5530cecff0be210b148bddf1e984ed31d2863c/docs/work/compression.rst
- permessage-deflate implementation in Autobahn package: https://github.com/crossbario/autobahn-python/blob/fd5530cecff0be210b148bddf1e984ed31d2863c/autobahn/websocket/compress_deflate.py#L70
- Example project to test Autobahn permessage_deflate compression: https://github.com/crossbario/autobahn-python/tree/master/examples/twisted/websocket/echo_compressed
Super, thanks @albertas — FYI I'm picking this up at the end of this week. Thanks for your input! 🎁
Hey @albertas — another update — I'm looking at this. Didn't make the Sept target, but Daphne is now my active thing. Thanks for your patience.
@carltongibson Is there a way I could help? :slightly_smiling_face:
Hey @albertas. Yes. Sorry. life.
I haven't had any bandwidth at all for anything in the last few weeks.
This issue is at the very top of my list, and will be the first I look at. (I've half looked and I think it's fine, but just need a cycle to confirm that to myself.)
My next target is a release for Daphne.
If you'd like to look at the other issues and PRs and think what's addressable for a release, that would be awesome. It is just me, so an extra hand in the medium term would make things more sustainable.
@albertas Just to give some guidance on that — in case you take me up on it 😄 — I'm thinking to update the dependencies, check the Windows compatibility with the latest twisted, look at #319 properly (despite the Django auto-reloader issues) and think about dropping PY36 and PY37 (since it's not clear task cancelling is being handled properly...) — There's plenty there to begin on.
Is there any progress with this pull-request? We are enabling permessage-deflate with a strange hack by searching the WebSocketFactory in the gc.get_objects()... Having this work out of the box would really be nice
@carltongibson Is there any chance of getting this PR forward? I could assist if needed.