Skip to content

Relay Websocket: Use permessage-deflate extension #1549

Closed

Description

@JeremyMahieu

Feature description

Instead of manually applying zlib, consider adding support for permessage-deflate websocket extension. Which is by default used in webbrowsers.

  1. Clients sets the Sec-WebSocket-Extensions: permessage-deflate; header for the websocket, browsers already do this
  2. Server (weechat) also sets the Sec-WebSocket-Extensions: permessage-deflate; header
  3. Server implements the compression and decompression: some sample in C

What does this impove:

  • Websocket now has compression in both directions. Before it was only in the server -> client direction.
  • Messages can be read in the dev console of the browser even with compression applied, very important for debugging
  • Clients can leave out extra libraries such as zlib's inflate.js and a bunch of code to facilitate this compression and let the browser handle it.
  • Perfectly backwards and forwards compattible: If the server does not set the header, there is no problem, it just won't be compressed, so backwards compatibility is fine. New clients will work with old weechat. In the other direction, because of the headers in the binary files, they will see it's uncompressed and it will also keep working. Or you could keep the zlib implementation server side and new clients would always choose compression=off.

Activity

  1. flashcode commented on Jan 14, 2024

    @flashcode
    Member

    Hi,

    First implementation is available in this development branch (target version is WeeChat 4.3.0, with a new api relay protocol): https://github.com/weechat/weechat/tree/relay-api

    Extension permessage-deflate works for both weechat and api protocols.

  2. self-assigned this
    on Jan 14, 2024
  3. added this to the 4.3.0 milestone on Jan 14, 2024
  4. JeremyMahieu commented on Feb 2, 2024

    @JeremyMahieu
    Author

    Amazing, thanks for your effort.

  5. flashcode commented on Feb 2, 2024

    @flashcode
    Member

    I forgot to mention here, this has been implemented while adding a new "api" relay (HTTP REST API), which was designed to fix the design of "weechat" protocol (permessage-deflate is supported in both), see: #2066.

    API protocol is under development, and when finished, it should deprecate completely the "weechat" protocol.

  6. added a commit that references this issue on Feb 3, 2024
    6cfb31c
  7. flashcode commented on Jun 2, 2024

    @flashcode
    Member

    Note: with WeeChat ≥ 4.3.2, the websocket extension "permessage-deflate" will be disabled with "weechat" protocol, see my comment in this glowing-bear issue.

  8. added 2 commits that reference this issue on Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

featureNew feature request

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions