A lot of things are going on here. TCP connection is channel level if you want to teardown the connection, you need to close the channel. shutdown and shutdownNow does not teardown the connection immediately, did you wait until termination?
You may consider using NettyServerBuilder#maxConnectionAge and NettyServerBuilder#maxConnectionAgeGrace on the server side to rebalance connections. If this doesn't solve the problem, you may want to implement your own load balancer which isn't bad but it is not a simple configuration. you may find this stackoverflow post useful: https://stackoverflow.com/questions/39643841/grpc-client-side-load-balancing On Mon, Jun 1, 2020 at 5:59 PM <[email protected]> wrote: > Hello! > > I'm accepting bidirectional streaming gRPC connections (grpc-java, Netty) > on a set of servers and are hoping to use DNS to route traffic. I'd like to > be able to update a DNS record to get a client to connect to a different > server as a method of load shifting. As the connections are long-lived, I'm > finding that clients need to be prompted to disconnect to refresh their DNS > entry and connect to the new server. I've tried several methods (returning > an error response to the observer in a stream method, closing the call in > the listener) but it looks like I'm able to close the channel, but never > the underlying TCP connection, and so the DNS refresh never happens. > > Is there a way to close a connection from the server in grpc-java? > Restarting the server prompts the client to refresh, as does setting a > maximum connection age, but I'd like to avoid the overhead of closing > connections on a cadence. > > Thanks! > > -- > You received this message because you are subscribed to the Google Groups " > grpc.io" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/grpc-io/dbd20923-dc3d-4271-a524-6d975672ff8c%40googlegroups.com > <https://groups.google.com/d/msgid/grpc-io/dbd20923-dc3d-4271-a524-6d975672ff8c%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CABu9GjorNcOP1KKvS7T3ADz3k%2BqqoNLKmK2zqKGdyOBMBtnrJA%40mail.gmail.com.
