grpc-java: DNS resolution expiration
It looks like the channel is somehow caching the IP resolved through DNS but never refreshing it. We are using grpc in AWS and since ELB’s IPs change over time, we’ve run into issues and found out grpc clients are trying to connect to an old IP.
Code snippet:
private[this] val channel = NettyChannelBuilder.forAddress(httpHost, httpPort).negotiationType(NegotiationType.PLAINTEXT).build();
private[this] val blockingStub = CrudGrpc.newBlockingStub(channel)
private[this] def getStub = blockingStub.withDeadlineAfter(timeout.toNanos, TimeUnit.NANOSECONDS)
override def getEntity(id: String): Entity = {
getStub.getEntity(id)
}
Is our assumption correct? Is there any issue in how are we using the client library? Would it be a bad practice (performance-wise at least) to create a new channel in each request?
Thanks in advance
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 17 (11 by maintainers)
I also encountered such problem, using Python as server, Java as client and appoint NettyChannelBuilder as the ManagedChannel builder, deploy in AWS with ELB, but IP changes over time. if I change ManagedChannel builder to ManagedChannelBuilder, the grpc-java version is 0.13.1, ManagedChannelBuilder using io.grpc.okhttp.OkHttpChannelProvider as provider seems to work fine.
Any suggestion on this?