-
Notifications
You must be signed in to change notification settings - Fork 583
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
Async API - socket read timeout has no effect #1492
Comments
cc @danielmarbach @bording @bollhals I'm pinging y'all because of what I've found with regard to an async read timeout. As I suspected, it can only be achieved using a This will probably affect performance negatively. What I have found, however, is that the heartbeat mechanism does eventually figure out when no data is coming over the socket, and closes the connection. However, with
I feel like I should focus on getting the heartbeat mechanism a bit more reactive in this situation. Thoughts? |
Can you expand a bit on what you mean by this? |
Well, there have been so many micro-optimizations in this library with regard to reducing object initialization and allocation I'm assuming the same would apply to this scenario. I can run some benchmarks, of course. I think taking a close look at heartbeats needs to happen anyway. |
Can you observe the timer queue counter behavior and take a dump? The timed CTS uses timers as far as I recall and it sounds like we are stalling there somehow. You could also try to pool the CTS and try reset them to see if it makes the problem occur less which could give us more intel too |
@danielmarbach there's no problem - when I use a cancellation token source with a timeout, the async read is cancelled as expected: My concern is about the performance cost of setting up a CTS for every call to that method. |
@lukebakken sorry I misunderstood the whole conversation. I think I would get started with the version you have in the linked code. You can then throw it under a benchmark if needed to compare to a more optimized version. I was thinking a bit about an optimized version but it could become quite cumbersome and potentially error prone. For example you could optimize stuff around the fact that there is only one mainloop and the read timeout rarely ever changes. That would make it possible to have a cancellation token source managed by the frame handler that is always reset after every Maybe there are also other solutions but this is all I could come up with in the limited time I had available. |
@danielmarbach I appreciate your input!
Yep, I considered that, but reset is not supported in I am going to add tests to ensure the heartbeat and continuation timeout feature adequately covers the scenario of a socket read timeout. I'm pretty sure it will. In that case, socket read and write timeouts should no longer be necessary. |
Fixes #1492 * Add dedicated test class for Toxiproxy * Start Toxiproxy via docker on GHA ubuntu runner * Start Toxiproxy in same Powershell session as `dotnet test` on GHA windows runner * Add toxiproxy-netcore as a submodule so that we can strong-name it. * Remove use of socket read timeout, and depend on heartbeats instead. * Remove duplicate tests * Use `ConcurrentBag` where necessary
Fixes #1492 * Add dedicated test class for Toxiproxy * Start Toxiproxy via docker on GHA ubuntu runner * Start Toxiproxy in same Powershell session as `dotnet test` on GHA windows runner * Add toxiproxy-netcore as a submodule so that we can strong-name it. * Remove use of socket read timeout, and depend on heartbeats instead. * Remove duplicate tests * Use `ConcurrentBag` where necessary
Fixes #1492 * Add dedicated test class for Toxiproxy * Start Toxiproxy via docker on GHA ubuntu runner * Start Toxiproxy in same Powershell session as `dotnet test` on GHA windows runner * Add toxiproxy-netcore as a submodule so that we can strong-name it. * Remove use of socket read timeout, and depend on heartbeats instead. * Remove duplicate tests * Use `ConcurrentBag` where necessary
Is your feature request related to a problem? Please describe.
The v7 async API uses .NET Pipelines and
ReadAsync
from aNetworkStream
inSocketFrameHandler
:https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/main/projects/RabbitMQ.Client/client/impl/SocketFrameHandler.cs#L284
https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/main/projects/RabbitMQ.Client/client/impl/Frame.cs#L257-L283
Even though we set a socket read timeout here, this will have no effect on an async read (docs)
So, this means that reads will never time out. This should be OK because we have heartbeats, but it would be great to have a test for this.
Describe the solution you'd like
A test for socket read timeout. It'll probably involve toxiproxy.
The text was updated successfully, but these errors were encountered: