0

I'm currently encountering this exception on my quarkus microservice running in JVM mode over Google cloud run.

The exception is being thrown when invoking a rest endpoint using Quarkus reactive rest-client (Quarkus service calling a rest endpoint), and I've determined the root cause and it is possibly due to the container resource constraints during startup time.

I've believed that is the issue as when compiling to Native or trying to do the same thing twice (meaning invoking the method that calls the endpoint twice) it does it without encountering the timeout exception.

2022-09-26 01:48:12.947 WET
Caused by: io.netty.handler.ssl.SslHandshakeTimeoutException: handshake timed out after 10000m

To elaborate on my issue, my rest client looks something like this

@RegisterRestClient(configKey = "sms-api")
@RegisterClientHeaders(SmsRepoHeaders.class)
public interface SmsRepo {
  @POST
  Uni<MsgReqStatusDto> sendSms(MsgReqDto msgReqDto);
}

The SmsRepoHeaders look like this

@ApplicationScoped
public class SmsRepoHeaders extends ReactiveClientHeadersFactory {

public Uni<MultivaluedMap<String, String>> getHeaders(MultivaluedMap<String, String> incomingHeaders, MultivaluedMap<String, String> clientOutgoingHeaders) {
    return authenticate().chain(token ->{
      MultivaluedMap<String, String> headers = new MultivaluedHashMap<>();
      headers.add("Authorization", token);
      return Uni.createFrom().item(headers);
    });
  }

public Uni<String> authenticate() {
    var creds = new LoginDto();
    creds.setUsername(apiKey);
    creds.setPassword(secretKey);

    return loginRepo.authenticate(creds)
        .chain(sessionDto ->
            Uni.createFrom().item("Bearer " +
                sessionDto.getAccessToken()));
  }
}

and the SslHandshakeTimeoutException is being thrown when I first call SmsRepo.sendSms(), I figured increasing the timeout might help? Also I'm invoking SmsRepo.sendSms() asynchronously, meaning the controller code is something like this.

@Inject
ManagedExecutor me;

@POST
public Uni<Void> sendSms(...) {
   me.execute(() -> smsRepo.sendSms(...));
   return Uni.createFrom().voidItem();
}

So for some reason SSL is timing out if I'm submitting the task through an executor, but when directly returning the Uni, like this...

@POST
public Uni<Void> sendSms(...) {
   return smsRepo.sendSms(...);
}

everything seems to work fine as well, as well, meaning there are three currently workarounds to avoid the issue

  • Compile and run using Native
  • Run it in an environment with more powerful resources (not having this issue when running on my local machine)
  • Don't call the method "asynchronously" by submitting it to an executor

also, I've tried using this config in the yaml config and it's the same issue

  rest-client:
    connect-timeout: 120000
    read-timeout: 120000

0 Answers0