3

I have this declarative client:

@Retryable(attempts = "5", multiplier = "1.2")
@Client("\${client-url}")
@Headers(
    Header(name = USER_AGENT, value = "Micronaut Http Client"),
)
interface MyApiClient {

    @Get("/locations?location={location}")
    suspend fun validationLocation(@QueryValue location: String) : LocationResponse
}

I've set the client timeout to 30s with:

micronaut:
 http:
    client:
      read-timeout: 30s

And randomly I am getting:

Client <package> received HTTP error response: Read Timeout
    2021-08-02T23:09:13.069278169Z io.micronaut.http.client.exceptions.ReadTimeoutException: Read Timeout
    2021-08-02T23:09:13.069283269Z  at io.micronaut.http.client.exceptions.ReadTimeoutException.<clinit>(ReadTimeoutException.java:26)
    2021-08-02T23:09:13.069287569Z  at io.micronaut.http.client.netty.DefaultHttpClient$11.exceptionCaught(DefaultHttpClient.java:2301)
    2021-08-02T23:09:13.069291069Z  at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:302)
    2021-08-02T23:09:13.069306269Z  at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:281)
    2021-08-02T23:09:13.069309969Z  at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:273)
    2021-08-02T23:09:13.069313269Z  at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireExceptionCaught(CombinedChannelDuplexHandler.java:424)
    2021-08-02T23:09:13.069316669Z  at io.netty.channel.ChannelHandlerAdapter.exceptionCaught(ChannelHandlerAdapter.java:92)
    2021-08-02T23:09:13.069319769Z  at io.netty.channel.CombinedChannelDuplexHandler$1.fireExceptionCaught(CombinedChannelDuplexHandler.java:145)
    2021-08-02T23:09:13.069323069Z  at io.netty.channel.ChannelInboundHandlerAdapter.exceptionCaught(ChannelInboundHandlerAdapter.java:143)
    2021-08-02T23:09:13.069326169Z  at io.netty.channel.CombinedChannelDuplexHandler.exceptionCaught(CombinedChannelDuplexHandler.java:231)
    2021-08-02T23:09:13.069329469Z  at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:302)
    2021-08-02T23:09:13.069332669Z  at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:281)
    2021-08-02T23:09:13.069335869Z  at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:273)
    2021-08-02T23:09:13.069339069Z  at io.netty.handler.timeout.ReadTimeoutHandler.readTimedOut(ReadTimeoutHandler.java:98)
    2021-08-02T23:09:13.069342369Z  at io.netty.handler.timeout.ReadTimeoutHandler.channelIdle(ReadTimeoutHandler.java:90)

What can the cause be to this very annoying behaviour?

user1984190
  • 135
  • 2
  • 5

2 Answers2

0

This question seems to concern the same issue: Micronaut ReadTimeoutException

Apparrently the configuration is not injected. You might have to set it programmatically.

TreffnonX
  • 2,924
  • 15
  • 23
0

Apparently removing the suspend from the function and making it return a Single<LocationResponse> made the time-outs disappear.

user1984190
  • 135
  • 2
  • 5