daphne icon indicating copy to clipboard operation
daphne copied to clipboard

Allow to accept websocket extensions

Open albertas opened this issue 5 years ago • 38 comments

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.

albertas avatar Sep 14 '20 11:09 albertas

Fixes #326

albertas avatar Sep 14 '20 12:09 albertas

Hey @carltongibson, could you please take a look at this PR. I could update it as needed.

albertas avatar Oct 19 '20 12:10 albertas

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!

carltongibson avatar Oct 19 '20 18:10 carltongibson

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?

albertas avatar Jan 04 '21 14:01 albertas

If I'm understanding correctly, Daphne doesn't support websocket extensions as-is and this PR would add support for that?

benrudolph avatar Jun 21 '21 14:06 benrudolph

@benrudolph If you wanted to pick this up and rebase it, I'd be happy to have a look.

carltongibson avatar Jun 22 '21 17:06 carltongibson

alrighty, i'll take a look

benrudolph avatar Jun 22 '21 19:06 benrudolph

Well, merge conflicts were trivial: only for added imports. I have solved them using web editor in no time. Looking forward for your reviews.

albertas avatar Jun 23 '21 10:06 albertas

So @benrudolph — does this allow you to do what you're after?

carltongibson avatar Jun 23 '21 11:06 carltongibson

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!

benrudolph avatar Jun 23 '21 16:06 benrudolph

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.

carltongibson avatar Jun 23 '21 17:06 carltongibson

Thanks appreciate it

benrudolph avatar Jun 23 '21 21:06 benrudolph

@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.

albertas avatar Jun 25 '21 09:06 albertas

oh amazing! 🔥 🔥 that's a huge win

benrudolph avatar Jun 25 '21 14:06 benrudolph

@carltongibson anything we can do to get this puppy in?

benrudolph avatar Jul 03 '21 00:07 benrudolph

@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. 🙂

carltongibson avatar Jul 03 '21 05:07 carltongibson

sounds good. wow! you're maintaining those 3 libraries solo?? that's simultaneously incredible and a little terrifying 👏

benrudolph avatar Jul 03 '21 06:07 benrudolph

It’s mostly terrifying. 😃 (folks do help, but input welcome!)

carltongibson avatar Jul 03 '21 06:07 carltongibson

bump

albertas avatar Aug 03 '21 23:08 albertas

@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.

albertas avatar Aug 26 '21 07:08 albertas

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?

carltongibson avatar Aug 26 '21 07:08 carltongibson

@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 avatar Aug 26 '21 08:08 carltongibson

@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

albertas avatar Aug 27 '21 23:08 albertas

Super, thanks @albertas — FYI I'm picking this up at the end of this week. Thanks for your input! 🎁

carltongibson avatar Sep 07 '21 08:09 carltongibson

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 avatar Oct 10 '21 17:10 carltongibson

@carltongibson Is there a way I could help? :slightly_smiling_face:

albertas avatar Oct 22 '21 13:10 albertas

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.

carltongibson avatar Oct 22 '21 14:10 carltongibson

@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.

carltongibson avatar Oct 22 '21 14:10 carltongibson

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

pbhd avatar Oct 30 '22 13:10 pbhd

@carltongibson Is there any chance of getting this PR forward? I could assist if needed.

albertas avatar Oct 30 '22 14:10 albertas