Java get request unable to retry indefinitely

I’m trying to indefinitely retry a get request using a custom RetryStrategy like this:

	Flux.just(1, 2, 3)
			.flatMap(i -> bucket.reactive().defaultCollection().get(String.valueOf(i), GetOptions.getOptions().retryStrategy((request, reason) -> {
				return CompletableFuture.completedFuture(RetryAction.withDuration(Duration.ZERO));

I see a bunch of “Retry” messages printed out but then after a while I get error

Exception in thread "main" com.couchbase.client.core.error.UnambiguousTimeoutException: GetRequest, Reason: TIMEOUT {"cancelled":true,"completed":true,"coreId":"0xd35b95e100000001","idempotent":true,"reason":"TIMEOUT","requestId":2,"requestType":"GetRequest","retried":224,"retryReasons":["BUCKET_OPEN_IN_PROGRESS"],"service":{"bucket":"test","collection":"_default","documentId":"2","opaque":"0x1","scope":"_default","type":"kv","vbucket":0},"timeoutMs":2500,"timings":{"totalMicros":2515363}}
	at com.couchbase.client.core.msg.BaseRequest.cancel(
	at com.couchbase.client.core.msg.Request.cancel(
	at com.couchbase.client.core.Timer.lambda$register$2(
	at java.base/
	Suppressed: java.lang.Exception: #block terminated with an error
		at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(
		at reactor.core.publisher.Mono.block(

Shouldn’t the RetryStrategy prevent this from happening?

@mico.piira I think you are mixing up two things: the operation timeout and the retry strategy. The operation timeout tells how long an operation should be allowed to take (including retries), and the retry strategy defines if and how the request should be retried.

Note that this only accounts for retries BEFORE the operation is complete. Once the operation is complete (and it failed), you want to use reactors reactive retry operators to retry the whole thing.

If you let me know what you are trying to achieve maybe I can help you with a proper solution.

Alright, I just saw some get requests timeouting in logs and the errors said “retries: 0”.

I thought the Java SDK would by default retry in such situations. I guess I will then have to use the reactor retry operator everywhere in my codebase or increase my timeouts.

Correct - the SDK will only retry what it can to drive an individual operation to completion with the best effort strategy. Once the op is complete, then it’s up to you to decide what to do (retry, fail, do something else), since every app has different needs.