Skip to content

Add support for permessage-deflate extension in websockets #2257

@dbinnersley

Description

@dbinnersley

Component(s)

router

Is your feature request related to a problem? Please describe.

I'm on a project where we're sending gigabytes of uncompressed data per second via websockets to clients. We currently have a homegrown implementation of subscriptions that we are using that doesn't use cosmo router, but we are looking to unify all of our requests through the router. One of the blockers in fully switching is enabling websocket message compression where we can cut down the amount of data transfer by up to 10x. This will improve cost/latency/scalability and decrease the amount of bandwidth required by customers using our services.

Describe the solution you'd like

permessage-deflate is a common value set in the Sec-Websocket-Extensions header. I'd like the router to be able to handle this extension, and be able to upgrade appropriately. The response I expect from the router to the client would be similar to follows on a connection upgrade:

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
Sec-WebSocket-Extensions: permessage-deflate

In addition, I would expect all the messages sent to/from the client after the upgrade to be compressed using deflate.

Describe alternatives you've considered

We can connect to subgraphs directly. We're using node for several of our subgraphs, and the WebSocketServer contains a perMessageDeflate parameter that can be configured. With this enabled, we get the behaviour that we want, however we can't access fields outside of the subgraph we are connecting to.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions