grpc-dart icon indicating copy to clipboard operation
grpc-dart copied to clipboard

Hang the call when internet is interrupted

Open phamnhuvu-dev opened this issue 4 years ago • 4 comments

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;
  }

phamnhuvu-dev avatar May 24 '21 16:05 phamnhuvu-dev

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.

mraleph avatar May 25 '21 12:05 mraleph

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

phamnhuvu-dev avatar May 25 '21 13:05 phamnhuvu-dev

I have a same problem, are there any updates?

RuslanBarcho avatar May 23 '22 00:05 RuslanBarcho

me too

Firemanpl avatar Jul 14 '23 05:07 Firemanpl