vmagamedov / grpclib

Pure-Python gRPC implementation for asyncio
http://grpclib.readthedocs.io
BSD 3-Clause "New" or "Revised" License
936 stars 92 forks source link

Reconnect channel automatically #115

Closed tamirOK closed 4 years ago

tamirOK commented 4 years ago

Is it possible for grpclib to reconnect channel automatically in case of network fail? For example. there is already established channel on client side. Then network stops working for 1 second and resets. Will the channel reconnects to server in this case?

Thanks!

vmagamedov commented 4 years ago

Channel closes connection as soon as asyncio notices that connection is broken: https://docs.python.org/3/library/asyncio-protocol.html#asyncio.BaseProtocol.connection_lost. After this happens Channel opens a new connection for a subsequent request.

It is possible to proactively detect a closed connection by using connection health-checks (periodic PING frames). This feature is still experimental and not documented. Here you can find some details: https://github.com/vmagamedov/grpclib/pull/96