beast icon indicating copy to clipboard operation
beast copied to clipboard

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

Open laper32 opened this issue 3 years ago • 4 comments

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.

laper32 avatar Sep 07 '22 17:09 laper32

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.

madmongo1 avatar Sep 07 '22 18:09 madmongo1

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

laper32 avatar Sep 08 '22 01:09 laper32

@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

klemens-morgenstern avatar Sep 24 '22 04:09 klemens-morgenstern

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.

madmongo1 avatar Sep 24 '22 04:09 madmongo1