grpc / grpc-dart

The Dart language implementation of gRPC.
https://pub.dev/packages/grpc
Apache License 2.0
860 stars 271 forks source link

channel getConnection() #652

Open Firemanpl opened 1 year ago

Firemanpl commented 1 year ago
I want to detect lost connection or not connection or failed connection. I found method channel.getConnection(), but It return object which returns useless method like shutdown etc. My question is simply. How to detect connection loss or connection failure and successful channel connection to the server ? It is possible ?. I found keepalive method on channel but it it gives me little to maintain the connection without any method that checks this connection. ``` class GrpcManager { late ClientChannel channel; //late MetadaztaClient stub; Future connect(List args) async { channel = ClientChannel( '127.0.0.1', port: 8080, options: const ChannelOptions( credentials: ChannelCredentials.insecure(), keepAlive: ClientKeepAliveOptions( pingInterval: Duration(seconds: 1), timeout: Duration(seconds: 10), permitWithoutCalls: true, ), ), ); // stub = MetadataClient(channel); final clientConnection = await channel.getConnection(); if (clientConnection.) {} await channel.shutdown(); } } ```