Skip to content

Consider adding in permessage-deflate support for websockets #2270

Open
@TheSkorm

Description

Hello,

We use mosquitto as an MQTT broker for the websockets endpoint of SondeHub.org. As an experiment to try to save bandwidth costs I implemented permessage-deflate in websockets.c and we saw significant reduction in bandwidth consumed.

image
image

While having permessage-deflate likely isn't suitable for everyone I think making it a configurable option would be very hand for many users and the changes to code is very minimal.

The way I hacked it in was modifying websockets.c to add

static const struct lws_extension extensions[] = {
        {
                "permessage-deflate",
                lws_extension_callback_pm_deflate,
                "permessage-deflate"
                 "; client_no_context_takeover"
                 "; client_max_window_bits"
        },
        { NULL, NULL, NULL /* terminator */ }
};

and in mosq_websockets_init add info.extensions = extensions; prior to lws_create_context

I then had to modify the docker file to include -lz in the linker for mosquitto build and changed LWS_WITHOUT_EXTENSIONS=OFF and -DLWS_WITH_ZLIB=ON in the lws build.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Component: mosquitto-brokerStatus: AcceptedIt's clear what the subject of the issue is about, and what the resolution should be.Type: EnhancementA new feature for a minor or major release.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions