Setting only totalTimeout is working from java library is not working


we are trying to set totalTimeout, but the get call is not getting timed out. For testing we have put the value as 1ms, still it is not timing out. But when we set socketTimeout also along with totalTimeout, the call is getting timed out with exception socket timeout. What is the correct way of setting timeout. Setting only totalTimeout is not sufficient?

We are java client version - 4.0.6


Code snippets? Logs? Server version? Can we get more info all around?


Blocking sockets have only one timeout value. SocketTimeout is used for that timeout. TotalTimeout is only checked on a socket timeout or other network error. Therefore, both socketTimeout and totalTimeout should be set for sync transactions. If retries are not desired, then socketTimeout and totalTimeout should be set to the same value.

For async transactions, totalTimeout can be set without setting socketTimeout. The reason is non-blocking sockets don’t have a timeout, so timeouts must be implemented independently in the event loop. The client’s async implementation uses totalTimeout as the socket timeout if socketTimeout is not set.

Also, many transactions will complete in less than 1ms. Use linux traffic control to induce extra network latency.


After giving this some thought, it does make sense for async and sync timeouts to behave in the same way. In the next client release, socketTimeout will automatically be set to totalTimeout when totalTimeout > 0 and socketTimeout is zero.