GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Allow configuring the windowBits and memLevel WebSocket compression (deflate) parameters on the server side · Issue #13083 · netty/netty

Allow configuring the windowBits and memLevel WebSocket compression (deflate) parameters on the server side #13083

New issue
Copy link
New issue
Copy link
Closed
#16809
Closed
Allow configuring the windowBits and memLevel WebSocket compression (deflate) parameters on the server side#13083
#16809
Copy link
Milestone
4.2.16.Final

Description

@devromik
devromik
opened on Dec 27, 2022
Issue body actions

We've been developing a WebSocket server that should be capable of handling a large number of parallel connections with compression enabled. Currently, there is no possibility to configure the windowBits and memLevel deflate parameters, and with the current hardcoded settings (windowBits: 15, memLevel: 8), the deflate implementation consumes a relatively large (too large in our case) amount of memory per connection: ~300 KB according to https://www.zlib.net/zlib_tech.html.

Please, consider making the windowBits and memLevel parameters configurable for both PerMessageDeflateServerExtensionHandshaker and DeflateFrameServerExtensionHandshaker handshakers.

For now, we have modified PerMessageDeflateServerExtensionHandshaker to support the windowBits parameter as follows:

...
int serverWindowSize = preferredAndMaxServerWindowSize; // int serverWindowSize = MAX_WINDOW_SIZE;
...
Iterator<Entry<String, String>> parametersIterator = extensionData.parameters().entrySet().iterator();

while (deflateEnabled && parametersIterator.hasNext()) {
    ...
    else if (SERVER_MAX_WINDOW.equalsIgnoreCase(parameter.getKey())) {
        // use provided windowSize if it is allowed
        if (allowServerWindowSize) {
            // RFC:
            // A server accepts an extension negotiation offer with this parameter
            // by including the "server_max_window_bits" extension parameter in the
            // extension negotiation response to send back to the client with the
            // same or SMALLER value as the offer.
            //
            // That's why we can reduce the client's proposal to preferredAndMaxServerWindowSize.
            serverWindowSize = min(parseInt(parameter.getValue()), preferredAndMaxServerWindowSize);

            if (serverWindowSize > MAX_WINDOW_SIZE || serverWindowSize < MIN_WINDOW_SIZE) {
                deflateEnabled = false;
            }
        } else {
            deflateEnabled = false;
        }
    }
    ...
}

We have also modified DeflateFrameServerExtensionHandshaker to support the windowBits parameter. According to the source code of DeflateFrameServerExtensionHandshaker, a client is not allowed to negotiate any parameters for the extension including max_window_bits, and, therefore, according to the RFC, must use the decompression window of the maximum size (15). This allows us to set any value for the parameter within the allowed range. We don't have to negotiate this value with the client.

Adding support for the memLevel parameter seems trivial for both handshakers.

Netty version

4.1.77.Final

Activity

  1. normanmaurer commented on Jan 2, 2023

    @normanmaurer
    normanmaurer
    on Jan 2, 2023
    Member
    More actions

    @devromik PRs welcome.

  2. devromik commented on Jan 3, 2023

    @devromik
    devromik
    on Jan 3, 2023
    Author
    More actions

    ok, we'll make a PR.

  3. normanmaurer
    added a commit that references this issue on Jun 12, 2026

    Make permessage-deflate server window size and memLevel configurable (#…

    This issue will close once commit 7bae566 is merged into the '4.2' branch.
    7bae566
  4. normanmaurer
    closed this as completedin #16809on Jun 12, 2026
  5. normanmaurer
    added a commit that references this issue on Jun 12, 2026

    Auto-port 5.0: Make permessage-deflate server window size and memLeve…

    This issue will close once commit 3f04a3e is merged into the '4.2' branch.
    3f04a3e
  6. normanmaurer
    added this to the 4.2.16.Final milestone on Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      • 4.2.16.Final

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.