Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

channel getConnection() #652

Open
Firemanpl opened this issue Jul 14, 2023 · 0 comments
Open

channel getConnection() #652

Firemanpl opened this issue Jul 14, 2023 · 0 comments

Comments

@Firemanpl
Copy link

Firemanpl commented Jul 14, 2023

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<void> connect(List<String> 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();
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants