How to mock "io.grpc.StatusRuntimeException: UNAVAILABLE: Network closed for unknown reason" when doing grpc call?

Viewed 24

I'm implementing a retry logic for my grpc call, when it saw StatusRuntimeException it will do retry several times. My question is how can I mock the call will throw StatusRuntimeException?

My thought is to set the alive time and alive timeout really small, like 5mills, is that works? Or is there any other good way to do that

NettyChannelBuilder.forAddress()
            .keepAliveTime(5, TimeUnit.MILLISECONDS)
            .keepAliveTimeout(5, TimeUnit.MILLISECONDS)
            .keepAliveWithoutCalls(true)
0 Answers
Related