Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Client gRPC connection with reconnect in C++?

Tags:

c++

grpc

Is it possible to have a client channel that automatically reconnects? I tried using wait_for_ready(true) on the context, but that doesn't seem to have any effect.

I get this crash when I try to use a client channel with a lost connection:

E0519 12:56:40.239405883    9379 client_context.cc:119]      assertion failed: call_ == nullptr
like image 265
Šimon Tóth Avatar asked May 19 '20 11:05

Šimon Tóth


People also ask

Does gRPC reconnect?

A gRPC channel will reconnect automatically.

How does gRPC connect?

A gRPC channel uses a single HTTP/2 connection, and concurrent calls are multiplexed on that connection. When the number of active calls reaches the connection stream limit, additional calls are queued in the client. Queued calls wait for active calls to complete before they are sent.

Can gRPC server call client?

Using the API Starting from a service definition in a . proto file, gRPC provides protocol buffer compiler plugins that generate client- and server-side code. gRPC users typically call these APIs on the client side and implement the corresponding API on the server side.

How does gRPC communicate?

Rather than using a textual format such as JSON or XML, gRPC uses a protocol buffer–based binary protocol to communicate with gRPC services and clients. Also, gRPC implements protocol buffers on top of HTTP/2, which makes it even faster for inter-process communication.


1 Answers

My problem was attempting to re-use a context. Creating a new context for each attempt fixed the issue.

like image 114
Šimon Tóth Avatar answered Oct 06 '22 01:10

Šimon Tóth