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

feature request: keep track of bandwidth usage #87

Closed
andrisi opened this issue Jan 17, 2022 · 7 comments
Closed

feature request: keep track of bandwidth usage #87

andrisi opened this issue Jan 17, 2022 · 7 comments

Comments

@andrisi
Copy link

andrisi commented Jan 17, 2022

Would be great to get the current total bandwidth usage of this component. So as I do requests through got for example, I could see how much proxy bandwidth I used up. Thanks!

@andrisi
Copy link
Author

andrisi commented May 22, 2022

@szmarczak any chance you could have a look at this and decide if you'd consider discussing it? Thanks!

@szmarczak
Copy link
Owner

Do you mean just HTTP/2 or both HTTP/2 and HTTP/1 requests?

@andrisi
Copy link
Author

andrisi commented May 22, 2022

Thanks for getting back to me. I mainly use HTTP/2, so for me that would help a lot, but I guess it would be a useful feature in general, as if you're using a metered proxy connection, it's good to know how much you "spend".

@szmarczak
Copy link
Owner

This is quite problematic, because the socket is unassigned when the session is closed. Node.js' idea is that you can't modify the socket, so probably that's why.

const http2 = require('http2');

const session = http2.connect('https://example.com');

session.once('close', () => {
    console.log(Boolean(session.socket)); // false
});

session.once('remoteSettings', () => {
    // However this works
    session.socket.once('close', function() {
        console.log(this.bytesRead);
    });

    session.close();
});

@szmarczak
Copy link
Owner

I think you might be looking for https://nodejs.org/api/perf_hooks.html#http2-http2-details

@szmarczak
Copy link
Owner

Ref: nodejs/node#22268

@andrisi
Copy link
Author

andrisi commented May 23, 2022

thanks @szmarczak

@andrisi andrisi closed this as not planned Won't fix, can't repro, duplicate, stale May 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants