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
Timeout for async_write, which must not happen at all #2865
Comments
Calling basic_stream::expires_after while there is a pending write operation, does not update the write timer: Because of If you change By the way, I believe we should update the documentation for |
For me it is surprising from the user's point of view, because a timeout simply occurs after a certain time, even though there are ALWAYS read and write operations. There is no period of time in which nothing happens, so that a timeout for anything at all would be justified. |
An easy fix would be to call |
I have already mentioned this in my request. But this is more of a workaround for me. |
The reason you can't update the write timer while it is pending is because it has already initiated an Could you please provide more context or clarify the specific logic or behavior you want to implement? You might consider updating a time point inside |
I just wanted to report this behavior, because according to the documentation it sounded to me like the timer should have been reset automatically with the next async_read(...). It was not clear to me that the write timeout would not be reset. "The timer applies collectively to any asynchronous reads or writes initiated after the expiration is set, until the expiration is set again" |
Maybe each async method could pull the last set expiry time, when it was not possible to set it before because of pending?
|
I think I have found a (adjustable!) bug where the timout of async_write() simply triggers, although it is not allowed to trigger!
I have only used the original example from boost.org slightly slimmed down.
If I now run this server (compiled with C++20, GCC13 under Linux Ubuntu 13.2.0 (other systems are also affected)
and then I use a http-client (uses http-pipelining + keepalive) that I wrote in go, I get a WRITE timeout
after firing MANY requests!
However, this may not appear here at all, because I call the "stream_.expires_after" before each asyn_read() call.
There are no visual delays and the TCP buffers are not full and according to the documentation,
the timeout should also apply to async_write. The system is underutilized, which means
that no timout may occur anywhere
You can find the server here:
https://coliru.stacked-crooked.com/a/bb251d267573feac
Start it with: ./beast_server_example 0.0.0.0 8080 4
The go client is here (build with: "go build ."):
https://coliru.stacked-crooked.com/a/1537cffa5303fb46
Start it with (wait 30-60 seconds): ./http_client / 10000000
I have also discovered a workaround.
When I add "stream_.expires_after(std::chrono::seconds(30))" ALSO before the async_write()-method, then I can send an
infinite number of requests. There is never a timout, not even after millions of requests.
So there is something unintuitive going on here. Maybe the problem here is that the timeout for async_write is simply not reset with every new async_read?
Check also the Docu:
expires_after
=> // Require that the read and write COMBINED take no longer than 30 seconds
=> stream.expires_after(std::chrono::seconds(30));
The text was updated successfully, but these errors were encountered: