grpc / grpc-dart

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

Hang the call when internet is interrupted #477

Open phamnhuvu-dev opened 3 years ago

phamnhuvu-dev commented 3 years ago

I am using grpc-dart on Flutter and I am facing a problem on the iOS but it works on Android and web, when the internet is interrupted, the call from client have never returned or thrown any errors.

grpc: ^3.0.0

Repro steps

  1. Run flutter app is using grpc on iOS
  2. Disconnecting the internet
  3. create a call from grpc client

Expected result: return or throw any errors

Actual result: the client call hang over

My workaround

import 'package:http/http.dart' as http;
import 'dart:io' show Platform;

  Future<ClientConnection> getConnection() async {
    if (_isShutdown) throw GrpcError.unavailable('Channel shutting down.');
    if (!_connected) {
      _connection = createConnection();
      _connected = true;
    }
    if (Platform.isIOS) {
      await http.get(Uri.parse('http://example.com/'));
    }
    return _connection;
  }
mraleph commented 3 years ago

Just to clarify: does the network go down during a gRPC call and you don't get any error or it just goes down before the call and you don't get any error? I guess it is the second one based on your reproduction steps.

phamnhuvu-dev commented 3 years ago

the internet goes down before the call. Then when I connected internet, these calls are sent to server.

RuslanBarcho commented 2 years ago

I have a same problem, are there any updates?

Firemanpl commented 1 year ago

me too