The Dart language implementation of gRPC.

Related tags

Templates dart grpc
Overview

The Dart implementation of gRPC: A high performance, open source, general RPC framework that puts mobile and HTTP/2 first.

CI status pub package

Learn more

For complete documentation, see Dart gRPC.

Supported platforms

Note: grpc-web is supported by package:grpc/grpc_web.dart. UDS-unix domain socket is supported with sdk version >= 2.8.0.

Contributing

If you experience problems or have feature requests, open an issue.

Note that we have limited bandwidth to accept PRs, and that all PRs require signing the EasyCLA.

Comments
  • Support gRPC-Web protocol

    Support gRPC-Web protocol

    See the gRPC-Web protocol document for details.

    We should be able to support this by making a GrpcWebChannel that implements the ClientChannel interface.

    type-enhancement 
    opened by jakobr-google 65
  • Support grpc-web in grpc-dart

    Support grpc-web in grpc-dart

    This is a work in progress, and I haven't gone down the path of implementing grpc-web yet, but I wanted to get some feedback on this refactor while I work on a GrpcWebTransport.

    Depending on feedback, I can abandon this PR and create another once that transport is done.

    One thing that needs to be done is there are no unit tests for the Http2Transport, only generalized transport.

    cla: yes 
    opened by fuzzybinary 55
  • Add support for unix domain sockets

    Add support for unix domain sockets

    When host start with "unix://", it will be parsed as unix socket, in other situations, it keep coincide with current code.


    Admin comment: Fixes https://github.com/grpc/grpc-dart/issues/299

    size/L 
    opened by llapx 29
  • Add decoded grpc-status-details-bin details to GrpcError

    Add decoded grpc-status-details-bin details to GrpcError

    Currently there is no way to access the details of a GrpcError in the Dart implementation. This PR adds the fully-typed details into the dart exception that gets thrown.

    This implements what's requested in #209.

    cc @jakobr-google as I saw you had a TODO comment in call.dart to do this someday.

    size/XXL 
    opened by acoutts 25
  • Minor changes to fix some major issues on mobile when using gRPC.

    Minor changes to fix some major issues on mobile when using gRPC.

    • Fixes bug when a ResponseStream is cancelled the underlying HTTP/2 stream is not disconnected so the transport never goes inactive/idle.
    • ~~Add connectTimeout to socket connections.~~
    • Fixes bug where connect state is mismanaged on socket error.
    cla: yes 
    opened by slightfoot 22
  • Unhandled exception when stream is cancelled

    Unhandled exception when stream is cancelled

    I use grpc-0.6.5 with the following code:

    main(List<String> args) async {
      await Server([Service()]).serve(port: 8022);
    
      final client = ServiceClient(ClientChannel(
        'localhost',
        port: 8022,
        options: const ChannelOptions(credentials: ChannelCredentials.insecure()),
      ));
    
      print(await client.method(Empty()).isEmpty);
      print(await client.method(Empty()).isEmpty); // line 18
    }
    
    class Service extends ServiceBase {
      @override
      Stream<Empty> method(ServiceCall call, Empty request) async* {
        yield request;
        yield request;
      }
    }
    

    and the proto:

    syntax = "proto3";
    import "google/protobuf/empty.proto";
    service Service {
      rpc Method (google.protobuf.Empty) returns (stream google.protobuf.Empty);
    }
    

    When I run the code (with Dart-2.0.0) I get the following output:

    false
    Unhandled exception:
    gRPC Error (14, Error making call: Bad state: The http/2 connection is no longer active and can therefore not be used to make new streams.)
    #0      main (file:///home/me/sample/bin/issue-grpc-stream.dart:18:9)
    <asynchronous suspension>
    #1      _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:277:32)
    #2      _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)
    Exited (255)
    

    Basically the code starts a server that provides a stream method. I call the method 2 times and use a .isEmpty on the resulting stream.

    It looks like the problem is about cancelling a stream (because .isEmpty cancel its subscription directly after receiving the first event).

    (I had a hard time to find what was the issue and I think it's an important issue)

    opened by a14n 20
  • feat: support client interceptors

    feat: support client interceptors

    Support client-side unary and streaming interceptors with similar interface to JS grpc-web interface. Interceptors are executed by Client.$createStreamingCall and Client.$createUnaryCall.

    size/L 
    opened by zbigniew-mandziejewicz-3r 18
  • Shelf middleware equivalent

    Shelf middleware equivalent

    Is there a shelf middleware equivalent ? I would like to know how much time is passed inside my endpoint. And maybe also get and release db connection from a pool inside it.

    type-question 
    opened by Kleak 15
  • ChannelCredentials.secure

    ChannelCredentials.secure

    <version of the grpc-dart packages used; see your pubspec.lock file>

    Repro steps

    1. step1
    2. step2
    3. step3

    Expected result:

    Actual result:

    Details

    <Include any other relevant details, logs, etc.>

    opened by qiuguian 14
  • generate stub doesn't work

    generate stub doesn't work

    When i launch this command : protoc --dart_out=grpc:lib/src/generated -Iprotos protos/metadata.proto i got the following error :

    protoc-gen-dart: program not found or is not executable
    --dart_out: protoc-gen-dart: Plugin failed with status code 1.
    

    i have installed everything (protoc and the protoc_plugin)

    opened by Kleak 14
  • Allow to make future chain request with ResponseFuture

    Allow to make future chain request with ResponseFuture

    Closes #413

    This PR allows to make future chain request with ResponseFuture:

      @override
      ResponseFuture<R> interceptUnary<Q, R>(ClientMethod<Q, R> method, Q request,
          CallOptions options, ClientUnaryInvoker<Q, R> invoker) {
        _invocations.add(InterceptorInvocation(_id, ++_unary, _streaming));
        return ResponseFuture.wrap(
                Future.delayed(Duration(seconds: 1), () => 'dummy'))
            .then((_) => invoker(method, request, _inject(options)))
            .then((foo) async => foo)
            .whenComplete(() => 'complete')
            .then((bar) => bar)
            .catchError((e, s) => print('$e at $s'))
            .timeout(Duration(seconds: 5));
      }
    
    size/M 
    opened by rockerhieu 13
  • Bump actions/checkout from 3.1.0 to 3.2.0

    Bump actions/checkout from 3.1.0 to 3.2.0

    Bumps actions/checkout from 3.1.0 to 3.2.0.

    Release notes

    Sourced from actions/checkout's releases.

    v3.2.0

    What's Changed

    New Contributors

    Full Changelog: https://github.com/actions/checkout/compare/v3...v3.2.0

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    size/XS dependencies 
    opened by dependabot[bot] 0
  • External gRPC

    External gRPC

    Interested in supporting external ASIO/gRPC C++, with a connection to Dart via isolate bridge.

    It's there an easy way to pass off a serialized gRPC messages in Dart to a virtual isolate, and parse incoming message from an isolate?

    I have an isolate zero-copy "bridge" working in both C++ and Rust.

    type-question 
    opened by jwinarske 7
  • Surprising behavior possible due to lower-case metadata keys

    Surprising behavior possible due to lower-case metadata keys

    Observation 1: As per the spec, "header field names MUST be converted to lowercase prior to their encoding in HTTP/2." This is enforced silently client-side in the _sanitizeMetadata method.

    Observation 2: On the server side, in ServiceCall the clientMetadata property is of type Map<String, String>.

    Consequence: If

    1. A user is not aware of the lower-case metadata key requirement; and
    2. is not aware of the Dart gRPC client's lower-casing of metadata keys; and
    3. uses metadata key names with upper case letters on the client/server

    then those metadata key names with upper case letters will not be retrieved on the server side, because there will be no keys with upper case letters in the clientMetadata map.

    Thus, it is humbly suggested to implement one of the following enhancements:

    1. Require that key names on the client side be provided by the user already lower case. In other words, rather than silently adjust them to lower case, throw i.e. an ArgumentError. (Obviously a potentially breaking change.)
    2. On the server side, use something other than vanilla Map for clientMetadata. This could be a map that treats keys as case-insensitive, or one that lower-cases incoming keys (i.e. in operator[]).

    P.S. Not just academic, I am the aforementioned unaware and surprised user. 😅

    opened by cbatson 0
  • [Feature Request] server-side

    [Feature Request] server-side "wrapper" interceptors

    Hello, I'd like to see something like Interceptors on the server side, but more akin to the UnaryInterceptor of gRPC-Web. This is something I have appreciated from other server frameworks. This style of interceptor would "wrap" around the service call, which yields the existing functionality of Interceptors (such as vetoing a request) and more. Such "wrapping" interceptors would be able to manipulate both the incoming request as well as the outgoing response.

    There are several interesting use cases for this. One such use case would be instrumenting all service calls in a uniform way.

    Interceptor 1
    |   Interceptor 2
    |   |   Interceptor 3
    |   |   |   service call
    |   |   Interceptor 3
    |   Interceptor 2
    Interceptor 1
    
    help wanted 
    opened by cbatson 2
  • Deadline exceeded errors do not contain stacktrace

    Deadline exceeded errors do not contain stacktrace

    No stack trace shown for dealine exceeded errors.

    (version: "3.1.0-dev")

    Repro steps

    1. checkout timeout branch from https://github.com/tarobins/grpc-dart/tree/timeout
    2. start helloworld example server
    3. run helloworld example client

    Expected result:

    Caught error: gRPC Error (code: 4, codeName: DEADLINE_EXCEEDED, message: Deadline exceeded, details: null, rawResponse: null, trailers: {})
    Stack trace
    
    That's all folks.
    robinsontom-macbookpro1 example/helloworld$ dart bin/client.dart
    Caught error: gRPC Error (code: 4, codeName: DEADLINE_EXCEEDED, message: Deadline exceeded, details: null, rawResponse: null, trailers: {})
    Stack trace
    #0      ClientCall._onTimedOut (package:grpc/src/client/call.dart:303:43)
    #1      Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
    #2      _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
    #3      _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
    #4      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
    
    That's all folks.
    

    Actual result:

    Caught error: gRPC Error (code: 4, codeName: DEADLINE_EXCEEDED, message: Deadline exceeded, details: null, rawResponse: null, trailers: {})
    Stack trace
    
    That's all folks.
    
    opened by tarobins 0
  • Connection terminated when calling Kalix service

    Connection terminated when calling Kalix service

    Using v3.0.2

    Repro steps

    1. Write a proto file using Google GRPC annotations + Kalix annotations
    2. Setup a service in Kalix and add client certificate
    3. Use curl and grpcurl like so to see expected response from service:
    % curl https://my.host.name:443/KalixRoute --key client.private.pem --cert client.crt -d '{"data_type":{}}' -H "Content-Type: application/json"
    [ExpectedError1]
    
    % grpcurl -cert client.crt -key iclient.private.pem my.host.name:443 com.my.service.SerivceName/ProtoRoute
    [ExpectedError2]
    
    1. Generate client using protoc
    2. See clients.dart code below
    3. In a ChangeNotifier:
    final RouteCommand request = RouteCommand(param: data!.toService());  //toService is a handrolled function to translate from FE domain to client domain
    serviceClient!.establishOrganization(request).then((reply) {     //serviceClient was setup in ChangeNotifier constructor succesfully
       print(reply)
       data = [...data, domain.DataType.fromService(reply)];  //fromService is another handrolled function to translate the other way
    });
    

    Expected result: being able to see the same kinds of expected errors as in step3, which are programmed into the Kalix service, printed in step 6 - or else the valid response when provided (both have been attempted) Actual result:

    Unhandled Exception: gRPC Error (code: 2, codeName: UNKNOWN, message: HTTP/2 error: Connection error: Connection is being forcefully terminated. (errorCode: 10), details: null, rawResponse: null, trailers: {})
    

    Details

    Since the Kalix service can be called with both curl and grpcurl to generate expected error messages, it seems my Dart code is likely the issue here. It is cobbled together from various examples and StackOverflows, so it is likely not all correct.

    #clients.dart

    ChannelCredentials creds = const ChannelCredentials.secure(authority: 'my.host.name');
    
    Future<Client> setupClient() async {
      ByteData caCert = await rootBundle.load('cert/ca.crt');
      ByteData cert = await rootBundle.load('cert/client.chain.crt');
      ByteData key = await rootBundle.load('cert/client.private.pem');
    
      creds.securityContext!.setTrustedCertificatesBytes(caCert.buffer.asUint8List(caCert.offsetInBytes, caCert.lengthInBytes,)
          .map((uint8) => uint8.toInt())
          .toList());
      creds.securityContext!.useCertificateChainBytes(cert.buffer.asUint8List(cert.offsetInBytes, cert.lengthInBytes,)
          .map((uint8) => uint8.toInt())
          .toList());
      creds.securityContext!.usePrivateKeyBytes(key.buffer.asUint8List(key.offsetInBytes, key.lengthInBytes,)
          .map((uint8) => uint8.toInt())
          .toList());
      creds.securityContext!.setAlpnProtocols(supportedAlpnProtocols, false);
    
    
      ClientChannel channel = ClientChannel(
        'my.host.name',
        port: 443,
        options: ChannelOptions(credentials: creds),
      );
      return MyServiceClient(channel);
    }
    
    opened by AlexWeinstein92 0
Releases(3.1.0)
  • 3.1.0(Oct 27, 2022)

    • Expose a stream for connection state changes on ClientChannel to address #428. This allows users to react to state changes in the connection.
    • Fix #576: set default :authority value for UDS connections to localhost instead of using UDS path. Using path triggers checks in HTTP2 servers which attempt to validate :authority value.
    Source code(tar.gz)
    Source code(zip)
  • 3.0.2(Aug 16, 2021)

  • 3.0.1(Aug 10, 2021)

    • Require package:googleapis_auth ^1.1.0
    • Fix issues #421 and #458. Validate responses according to gRPC/gRPC-Web protocol specifications: require 200 HTTP status and a supported Content-Type header to be present, as well as grpc-status: 0 header. When handling malformed responses make effort to translate HTTP statuses into gRPC statuses.
    • Add GrpcOrGrpcWebClientChannel which uses gRPC on all platforms except web, on which it uses gRPC-web.
    • GrpcError now exposes response trailers via GrpcError.trailers.
    Source code(tar.gz)
    Source code(zip)
  • 3.0.0(Aug 10, 2021)

  • 2.9.0(Jan 28, 2021)

    • Added support for compression/decompression, which can be configured through ChannelOptions constructor's codecRegistry parameter or adding the grpc-accept-encoding to metadata parameter of CallOptions on the client side and codecRegistry parameter to Server on the server side. Outgoing rpc can be compressed using the compression parameter on the CallOptions.
    • Fix issue #206. Prevent an exception to be thrown when a web connection stream is closed.
    • Add XHR raw response to the GrpcError for a better debugging (PR #423).

    Note: this is the last release supporting SDK < 2.12. Next release will be nullsafe and thus require SDK >= 2.12.

    Source code(tar.gz)
    Source code(zip)
  • 2.8.0(Nov 12, 2020)

    • Added support for client interceptors, which can be configured through Client constructor's interceptors parameter. Interceptors will be executed by Client.$createStreamingCall and Client.$createUnaryCall. Using interceptors requires regenerating client stubs using version 19.2.0 or newer of protobuf compiler plugin.
    • Client.$createCall is deprecated because it does not invoke client interceptors.
    • Fix issue #380 causing incorrect duplicated headers in gRPC-Web requests.
    • Change minimum required Dart SDK to 2.8 to enable access to Unix domain sockets.
    • Add support for Unix domain sockets in Socket.serve and ClientChannel.
    • Fix issue #331 causing an exception in GrpcWebClientChannel.terminate().
    Source code(tar.gz)
    Source code(zip)
  • 2.7.0(Oct 30, 2020)

    2.7.0

    • Added decoding/parsing of grpc-status-details-bin to pass all response exception details to the GrpcError thrown in Dart, via #349.
    • Dart SDK constraint is bumped to >=2.3.0 <3.0.0 due to language version in the generated protobuf code.

    2.6.0

    • Create gRPC servers and clients with [Server|Client]TransportConnnection. This allows callers to propvide their own transport configuration, such as their own implementation of streams and sinks instead of sockets.

    2.5.0

    • Expose a validateClient method for server credentials so gRPC server users may know when clients are loopback addresses.

    2.4.1

    • Plumb stacktraces through request / response stream error handlers.
    • Catch and forward any errors decoding the response.

    2.4.0

    • Add the ability to bypass CORS preflight requests.
    Source code(tar.gz)
    Source code(zip)
  • v0.4.1(Apr 5, 2018)

  • v0.4.0(Mar 19, 2018)

    • Moved TLS credentials for server into a separate class.
    • Added support for specifying the address for the server, and support for serving on an ephemeral port.
    Source code(tar.gz)
    Source code(zip)
  • v0.3.1(Feb 27, 2018)

  • v0.3.0(Feb 5, 2018)

    • Added authentication metadata providers, optimized for use with Google Cloud.
    • Added service URI to metadata provider API, needed for Json Web Token generation.
    • Added authenticated cloud-to-prod interoperability tests.
    • Refactored connection logic to throw initial connection errors early.
    Source code(tar.gz)
    Source code(zip)
  • v0.2.1(Jan 18, 2018)

  • v0.2.0(Dec 15, 2017)

    • Implemented support for per-RPC metadata providers. This can be used for authentication providers which may need to obtain or refresh a token before the RPC is sent.
    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Oct 12, 2017)

    • Core gRPC functionality is implemented and passes gRPC compliance tests.

    The API is shaping up, but may still change as more advanced features are implemented.

    Source code(tar.gz)
    Source code(zip)
Owner
grpc
A high performance, open source, general-purpose RPC framework
grpc
Public interface definitions of Google APIs for Dart and gRPC

Public interface definitions of Google APIs for Dart and gRPC. Getting started I

Mahdi K. Fard 1 Feb 23, 2022
Flutter language pickers2 - Language pickers package for Dart and Flutter

language_pickers2 Notes: Original repository from github.com/gomgom, unfortunate

Charles Dyason 0 Feb 6, 2022
flutter grpc video app && microsoft text to speech

flutter_video_app Getting Started Install dart protoc_plugin pub global activate protoc_plugin Clone WarpDriveProtocol git clone [email protected]

Liberxue 4 Sep 1, 2022
FIDL(Flutter Interface Definition Language) is a language for transfer objects cross platforms.

Flutter Interface Definition Language (FIDL) README in English(TODO) FIDL 即 Flutter 接口定义语言,类似于AIDL(Android Interface Definition Language)。您可以利用它定义不同平台

null 47 Dec 7, 2022
null 1 Jan 8, 2022
Implementation of data structures and algorithms in Dart programming language.

Algorithms in Dart Implementation of several algorithms with Dart programming language. Use dartdoc to generate documentation. Lists List data structu

Mafinar Khan 197 Dec 24, 2022
Lite-graphql - A light way implementation of GraphQL client in dart language

lite GraphQL client A light way implementation of GraphQL client in dart languag

Vincenzo Palazzo 3 Mar 17, 2022
Get It - Simple direct Service Locator that allows to decouple the interface from a concrete implementation and to access the concrete implementation from everywhere in your App. Maintainer: @escamoteur

❤️ Sponsor get_it This is a simple Service Locator for Dart and Flutter projects with some additional goodies highly inspired by Splat. It can be used

Flutter Community 1k Jan 1, 2023
Docker images for the Dart programming language (https://dart.dev)

dart-docker This is the Git repo of the Docker "Official Images" for the Dart programming language. See the Docker Hub page for a full description on

Dart 49 Dec 14, 2022
Intel Corporation 238 Dec 24, 2022
This repository was created to provide the basics of the Dart programming language and Its use cases.

dart-exercises A collection of source code of the Dart Programming language. How does this repository works? Clone / Fork this repository to make your

Technosoft Labs 2 Oct 28, 2021
Repo for Teach Yourself mastering dart programming language

mastering-dart Repo for Teach Yourself mastering dart programming language Chapter Membuat Aplikasi Pertama Menggunakan Dart Percabangan Perulangan Fu

Feri Lukmansyah 50 Nov 10, 2022
Dart library for some Turkish language specific operations.

turkish This library provides these functions for Turkish language for Dart: Converting strings to lower, upper and title case. Regular and ignore cas

Ahmet A. Akın 39 Dec 27, 2022
App concept created with Flutter using Dart programming language, inspired by Groceries Shopping App Interaction.

Grocery Shop Flutter App concept created with Flutter using Dart programming language, inspired by Groceries Shopping App Interaction. About The app w

Wilton Neto 485 Dec 9, 2022
The component created with Flutter using Dart programming language, inspired in Fluid Slider by Ramotion.

Fluid Slider Flutter The component created with Flutter using Dart programming language, inspired in Fluid Slider by Ramotion. About The component was

Wilton Neto 41 Sep 30, 2022
Todo is an Simple Task Management App coded using Dart which is a peogramming language for Flutter SDK(2.5) supports Null Safety 📑🚩

Todo ?? ?? ?? Introduction Todo is an Simple Task Management App coded using Dart which is a peogramming language for Flutter SDK(2.5) supports Null S

navee-ramesh 6 Nov 5, 2022
Fetching API with dart language.

TODO: Put a short description of the package here that helps potential users know whether this package might be useful for them. Features TODO: List w

Hemant Gauhai 1 Dec 21, 2021
A simple yet elegant tip calculator created using flutter framework and dart language.

CAL- TIP, A TIP CALCULATOR APPLICATION A simple yet elegant tip calculator created using flutter framework and dart language. As the name suggests, th

Nitin Verma 0 Dec 26, 2021
This application was created using the Dart language and it is an application that contains a set of different questions and at the end shows you the number of correct answers you have answered , made by flutter

exams_app A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if thi

null 0 Dec 28, 2021