Ozturk
Ozturk

Reputation: 609

How can gRPC client know about network loss/failure?

There is a server-side streaming in java project by using grpc. When the network was broken between server and client, the client doesn't even know about the problem, the streamobserver is idle and no activity. How can I know about this disconnection?

Upvotes: 0

Views: 1926

Answers (1)

voidzcy
voidzcy

Reputation: 610

You do not know the connection broken until sending a message. That's how TCP protocol works.

So if you are in the middle of server-side streaming and suddenly unplugged your modem, the client side would never know until the OS closes the socket (may take minutes).

You could either change to implement bidi-streaming that the client sends requests periodically so it knows network failures when trying to write to the socket, or you can enable keepAlive.

Upvotes: 1

Related Questions