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

[Question] Control the download speed/upload speed on SSL stream #2516

Open
laper32 opened this issue Sep 7, 2022 · 4 comments
Open

[Question] Control the download speed/upload speed on SSL stream #2516

laper32 opened this issue Sep 7, 2022 · 4 comments

Comments

@laper32
Copy link

laper32 commented Sep 7, 2022

I want to upload a file to a server, but I want to control my upload rate.
Since we are now using SSL, however, I have no idea how to control the rate under this case...

The tcp_stream have function to control the rate directly, so what should I do in order to control the rate with the ssl_stream? cuz I've searched the code about ssl_stream, that I didn't find anything about controlling the rate...

Perhaps it may be a little mess since it is not well organized.

@madmongo1
Copy link
Collaborator

madmongo1 commented Sep 7, 2022

You can either intersperse each invocation of async_read_some with a delay based on how much data was read since the last read, or you can write your own rate_limited_stream type that implements the AsyncReadStream concept.

The first method is the easiest.

Are you using HTTP or Websockets? Callbacks or coroutines? If you need more guidance I can write a little demo.

@laper32
Copy link
Author

laper32 commented Sep 8, 2022

Are you using HTTP or Websockets?

In fact I'm now using both (my library is required to support both of them)

Callbacks or coroutines?

I'm now using coroutines

If you need more guidance I can write a little demo.

Oh really? I just thought how can I implement it.
Thanks for your kind

@klemens-morgenstern
Copy link
Collaborator

@madmongo1 How'd you go about this? Drop in a delay between calls to async_read_some? I wonder if rate-limited ops could be a nice demo of async_compose

@madmongo1
Copy link
Collaborator

Couple of ways, depending big on whether you’re looking to have a hard cap on bit rate or want to have a constant average bit rate.

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

3 participants