Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uWebSocket: allow to specify compression option #633

Closed
yosiat opened this issue Dec 23, 2021 · 7 comments
Closed

uWebSocket: allow to specify compression option #633

yosiat opened this issue Dec 23, 2021 · 7 comments
Labels
enhancement New feature or request

Comments

@yosiat
Copy link
Contributor

yosiat commented Dec 23, 2021

Hi,

I am so excited about uWebSocket support and I want to roll it out, but I saw uWebSocket have support for multiple compression options - SHARED_COMPRESSOR, DEDICATED, etc.. and I would like to tune it for my application use-case.

https://unetworking.github.io/uWebSockets.js/generated/interfaces/WebSocketBehavior.html#compression

Is is possible to expose from socket.io to pass an option to engine.io to allow configuration compression option here -
https://github.com/socketio/engine.io/blob/master/lib/userver.ts#L50

I can implement it, but not sure what's the best way (to have this as "generic" option and not transport specific)

@yosiat yosiat added the enhancement New feature or request label Dec 23, 2021
@yosiat yosiat changed the title uWebSocket: allow to specify compression uWebSocket: allow to specify compression option Dec 23, 2021
@yosiat
Copy link
Contributor Author

yosiat commented Dec 23, 2021

In addition it will be nice to pass drain function so I can create metric on buffered amount to see if that requires tuning

@darrachequesne
Copy link
Member

That's a great idea! Would you have time to open a pull request?

@yosiat
Copy link
Contributor Author

yosiat commented Dec 28, 2021

@darrachequesne yes, but since this uwebsocket specific option how you want to model it? is it make sense to add uWebSocket configuration under ServerOption type?

@darrachequesne
Copy link
Member

@yosiat it should work with an union type:

public attach(app /* : TemplatedApp */, options: AttachOptions & { compression?: number } = {}) {
    const path = (options.path || "/engine.io").replace(/\/$/, "") + "/";
    // ...
}

What do you think?

@yosiat
Copy link
Contributor Author

yosiat commented Jan 9, 2022

@darrachequesne sounds good and then we will pass this union here as well - https://github.com/socketio/socket.io/blob/master/lib/index.ts#L353 ?

@darrachequesne
Copy link
Member

Yes 👍

darrachequesne pushed a commit that referenced this issue Jan 14, 2022
You can now pass additional options:

```js
const { App } = require("uWebSockets.js");
const { uServer } = require("engine.io");

const app = new App();
const server = new uServer();

server.attach(app, {
  compression: uWS.DEDICATED_COMPRESSOR_128KB, // defaults to none
  idleTimeout: 60, // defaults to 120
  maxBackpressure: 8 * 1024 // defaults to 1024 * 1024
});

app.listen(3000);
```

Related: #633
@darrachequesne
Copy link
Member

This has been implemented in 49bb7cf, and included in engine.io@6.1.2. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants