Connect Timeoutsedit
Connect timeouts can be overridden on a per request basis. Whilst the underlying WebRequest
(in the case of full CLR)
and HttpClient
(in the case of Core CLR) cannot distinguish between connect and retry timeouts,
we use a separate configuration value for ping requests.
we set up a 10 node cluster with a global time out of 20 seconds. Each call on a node takes 10 seconds. So we can only try this call on 2 nodes before the max request time out kills the client call.
var audit = new Auditor(() => Framework.Cluster .Nodes(10) .Ping(p => p.SucceedAlways().Takes(TimeSpan.FromSeconds(20))) .ClientCalls(r => r.SucceedAlways()) .StaticConnectionPool() .Settings(s => s.RequestTimeout(TimeSpan.FromSeconds(10)).PingTimeout(TimeSpan.FromSeconds(10))) );
The first call uses the configured global settings, request times out after 10 seconds and ping calls always take 20, so we should see a single ping failure
On the second request we set a request ping timeout override of 2seconds We should now see more nodes being tried before the request timeout is hit.
audit = await audit.TraceCalls( new ClientCall { { PingFailure, 9200 }, { MaxTimeoutReached } }, new ClientCall(r => r.PingTimeout(TimeSpan.FromSeconds(2))) { { PingFailure, 9202 }, { PingFailure, 9203 }, { PingFailure, 9204 }, { PingFailure, 9205 }, { PingFailure, 9206 }, { MaxTimeoutReached } } );