question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

gRPC client try to reconnect subchannel about 20 Seconds after I make the gRPC server network unreachable

See original GitHub issue

Please answer these questions before submitting your issue.

What version of gRPC are you using?

gRPC1.5.0

What JVM are you using (java -version)?

JDK1.8.0

What did you do?

If possible, provide a recipe for reproducing the error. 1、I create gRPC client and gRPC server in different host, 2、Send message to server interval of one second 3、Disable network to make the network from client to server unreachable.(unplug the server‘s cable)

What did you expect to see?

I want to see the client can quickly respond to the service unavailable as far as possible, rather than wait for about 20 seconds to know that the server is unavailable.

What did you see instead?

I see that the NettyClientHandler will do the onConnectionError after about 20 seconds, what Throwable it catch is

Status{code=UNAVAILABLE, description=null, cause=java.io.IOException: The remote host forced an existing connection to be closed

Then ManagedChannelImpl will handle the handleSubchannelState, make the subchannel to IDLE and try to reconnect. But I don’t understand What’s the mechanism? How does the client feel disconnected from the server network. And is there some methods that the client is able to perceive the server unavailable state more quickly!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ericgribkoffcommented, Sep 12, 2017

The ~20 second timeout is likely coming from the socket timing out, which is OS-dependent. It’s possible in other environments to wait much longer when the network is dropped before the client realizes it can’t communicate with the server. You can use gRPC’s keep-alives to get a more reliable timeout here, see https://github.com/grpc/grpc-java/blob/master/netty/src/main/java/io/grpc/netty/NettyChannelBuilder.java#L278. The current minimum keep-alive interval is 10 seconds, see https://github.com/grpc/grpc-java/blob/master/core/src/main/java/io/grpc/internal/KeepAliveManager.java#L231.

0reactions
ejona86commented, Sep 15, 2017

getState(true) will trigger a connection without an RPC. If the connection fails, then the Channel state will become TRANSIENT_FAILURE.

Read more comments on GitHub >

github_iconTop Results From Across the Web

gRPC client try to reconnect subchannel about 20 Seconds after I ...
I want to see the client can quickly respond to the service unavailable as far as possible, rather than wait for about 20...
Read more >
gRPC C++ client blocking when attempting to connect ...
As an experiment, I implemented some code to only try to connect on 1 channel (the non-functioning one in this case), and then...
Read more >
gRPC client auto reconnect - Google Groups
I'm new to using gRPC framework! What will happen if the gRPC server process terminates and is restarted after few seconds for e.g....
Read more >
gRPC Connectivity Semantics and API
States of Connectivity. gRPC Channels provide the abstraction over which clients can communicate with servers.The client-side channel object can be ...
Read more >
grpc/grpc - Gitter
What helps is to simply recreate a channel (gracefully shutting down the old one so it can finish in-flight requests) and then retry....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found