Giter VIP home page Giter VIP logo

grpc-dart's Introduction

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.

grpc-dart's People

Contributors

a14n avatar ankur2136 avatar bgetsug avatar chalin avatar cyrax111 avatar dependabot[bot] avatar disdis avatar domesticmouse avatar herrera93 avatar iinozemtsev avatar jakobr-google avatar kengu avatar kevmoo avatar leafpetersen avatar listepo avatar llapx avatar mattyboy4444 avatar mehmetf avatar michaelrfairhurst avatar mightyvoice avatar mit-mit avatar morgwai avatar mosuem avatar mraleph avatar natebosch avatar nichite avatar ruicraveiro avatar sigurdm avatar wapa5pow avatar zbigniew-mandziejewicz-3r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grpc-dart's Issues

"Cannot add event after closing" server error when client abruptly goes away

Run server from hello world example.
Run client and kill it. Repeat many time
Time to time, killing the client cause server crash. See trace bellow.

Also the client is very slow (4 request per sec). Don't know if related or not.

GRPC Version : from the repository (../..) (0.4.0 ?)

Repro steps

See above.

Details

Server Stack Trace:

Unhandled exception:
Bad state: Cannot add event after closing
#0      _StreamController.add (dart:async/stream_controller.dart:584)
#1      _StreamSinkWrapper.add (dart:async/stream_controller.dart:858)
#2      TransportStream.sendHeaders (package:http2/transport.dart:241:10)
#3      ServerHandler.sendTrailers (package:grpc/src/server/handler.dart:310:13)
#4      ServerHandler._sendError (package:grpc/src/server/handler.dart:359:5)
#5      ServerHandler._onResponse (package:grpc/src/server/handler.dart:248:7)
#6      _RootZone.runUnaryGuarded (dart:async/zone.dart:1316)

My Quick and dirty workaround : handler.dart: 248
try {
_sendError(grpcError);
} catch(err) {
print(err);
}

Question|Feature: Sending Binary Metadata

The grpc spec allows for sending metadata-bin as binary metadata. Is this currently supported?

v0.4.0

Repro steps

  1. Create a grpc-dart client to connect to a server

  2. Create a client call including a binary metadata key with a text value

    channel.stub.myMethod(new Request(), options: new CallOptions(metadata: {
      "testmetadata": "a string",
      "testmetadata-bin": "supposed to be binary"
    }, timeout: new Duration(seconds: 15))).then((Response response) {
      print(response);
    }).catchError((GrpcError error) {
      print("******* ${error.message} ******");
    });

Expected result: The request should either throw an error about malformed *-bin metadata, or discard the metadata

Actual result: The request sends the metadata, but there's a failure on the server (tested with NodeJS and Java)

Details

The request seems to silently fail on both NodeJS and Java, I tried getting log output, but couldn't find anything. I use nghttpx as my proxy, and it passed the testmetadata-bin as I supplied it.

One of the reasons why I use binary metadata is to pass my custom error messages as protobuf messages. I suppose it's a question for another day, but how would I deal with bytedata in dart? Do I use Uint8List?

upgrade to dart sdk 2.0 in pubspec for examples and cross test with golang

Can you change the pubspec to use the latest Dart SDK ?

Most dart libs are upgraded and this is breaking my project.

Reproduction:


cd github.com/grpc/grpc-dart/example/route_guide && pub get
Resolving dependencies...
The current Dart SDK version is 2.1.0-dev.3.0.flutter-760a9690c2.

Because route_guide requires SDK version >=1.24.3 <2.0.0,

EDIT:
It seems protobuf & test is the issue, as when i changed the versions for each to get it working

Here is the working and tested pubspec. Dart server and Dart client work with each other.
However Go server with Dart client do NOT work.
See my make file below for all testing. Very easy:

name: route_guide
description: Dart gRPC sample client and server.
homepage: https://github.com/dart-lang/grpc-dart

environment:
  sdk: '>=2.0.0-dev.58.0 <3.0.0'

dependencies:
  async: '>=1.13.3 <3.0.0'
  grpc:
    path: ../../
  protobuf: ^0.10.1

dev_dependencies:
  test: ^1.0.0

Make file for testing interop:

# Get golang server and dart client talking over grpc.

# dart Walkthrough : https://grpc.io/docs/tutorials/basic/dart.html
# go equivalent: https://github.com/grpc/grpc-go/tree/master/examples/route_guide

DART_LIBPATH=github.com/grpc/grpc-dart
DART_LIBGOPATH=$(GOPATH)/src/$(DART_LIBPATH)

GO_LIBPATH=google.golang.org/grpc
GO_LIBGOPATH=$(GOPATH)/src/$(GO_LIBPATH)


print:
	@echo 
	@echo DART_LIBPATH $(DART_LIBPATH)
	@echo DART_LIBGOPATH $(DART_LIBGOPATH)
	@echo 
	@echo GO_LIBPATH $(GO_LIBPATH)
	@echo GO_LIBGOPATH $(GO_LIBGOPATH)

dep-os:
	#go get golang.org/x/mobile/cmd/gomobile
	#gomobile init # it might take a few minutes

	# get the dart protoc plugin
	pub global activate protoc_plugin

dep:
	go get -u $(GO_LIBPATH)
	go get -u $(DART_LIBPATH)


dep-clean:
	rm -rf $(DART_LIBGOPATH)
	rm -rf $(GO_LIBGOPATH)


## Golang stuff


go-open-code:
	code $(GO_LIBGOPATH)/examples/route_guide

go-build:
	#cd $(GO_LIBGOPATH)/examples/route_guide && protoc -I protos/ routeguide/route_guide.proto --go_out=grpc:routeguide/generated

	cd $(GO_LIBGOPATH)/examples/route_guide/server && go generate

go-run-server:
	cd $(GO_LIBGOPATH)/examples/route_guide/server && go run server.go -json_db_file $(GO_LIBGOPATH)/examples/route_guide/testdata/route_guide_db.json -port 8080 -tls=true

go-run-client:
	cd $(GO_LIBGOPATH)/examples/route_guide/client && go run client.go -server_addr 127.0.0.1:8080 -tls=true



## Flutter stuff

dart-open-code:
	code $(DART_LIBGOPATH)

dart-build:
	cd $(DART_LIBGOPATH)/example/route_guide && pub get

	# gen dart server
	cd $(DART_LIBGOPATH)/example/route_guide && protoc -I protos/ protos/route_guide.proto --dart_out=grpc:lib/src/generated

	# gen golang server
	#cd $(DART_LIBGOPATH)/example/route_guide && protoc -I protos/ protos/route_guide.proto --go_out=grpc:go/generated


dart-run-server:
	# run server
	cd $(DART_LIBGOPATH)/example/route_guide && dart bin/server.dart

dart-run-client:
	# run server
	cd $(DART_LIBGOPATH)/example/route_guide && dart bin/client.dart -tls=true
	

ft-build-ios:
	# do this to bootstrap IOS befroe you start coding.
	cd caddy/example && flutter build ios --no-codesign

ft-open-ios:
	# open xcode proj.
	open caddy/example/ios/Runner.xcworkspace

ft-run-ios:
	cd caddy/example && flutter run






Flutter - OS Error: Connection refused

I am using protobuf and gRPC to exchange information between a Flutter app and a python server (client in Flutter and the server in python). Server running on 0.0.0.0 and the client is using the IP address of the server machine.

import 'dart:async';
import 'User.pbgrpc.dart';
import 'User.pb.dart';
import 'package:grpc/grpc.dart';

Future<Null> main() async {
  final channel = new ClientChannel('IP_ADDRESS',
      port: 50051,
      options: const ChannelOptions(
          credentials: const ChannelCredentials.insecure()));
  final stub = new StorageClient(channel);

  Test input = new Test();
  input.id = 1;
  try {
    var response = await stub.getPerson(input);
    print('Greeter client received: ${response}');
  } catch (e) {
    print('Caught error: $e');
  }
  await channel.shutdown();
}

if I run this client using dart client.dart everything works fine and I get the expected response. But if I embed this method in a flutter app like:

@override
Widget build(BuildContext context) {

Future<Null> testRPC() async {
  final channel = new ClientChannel('IP_ADDRESS',
      port: 50051,
      options: const ChannelOptions(
          credentials: const ChannelCredentials.insecure()));
  final stub = new StorageClient(channel);

  Test input = new Test();
  input.id = 1;
  try {
    var response = await stub.getPerson(input);
    print('Greeter client received: ${response}');
  } catch (e) {
    print('Caught error: $e');
  }
  await channel.shutdown();
}

testRPC();
...etc
}

I get:

I/flutter (18824): Caught error: gRPC Error (14, Error connecting: SocketException: OS Error: No route to host, errno = 111, address = localhost, port = 45638)

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)

Could grpc-dart work on secure state? example are just the 'insecure' .

here are the example for client
https://github.com/grpc/grpc-dart/blob/master/example/route_guide/lib/src/client.dart
and the client cold are here:
channel = new ClientChannel('127.0.0.1',
port: 8080,
options: const ChannelOptions(
credentials: const ChannelCredentials.insecure()));
the example are same as the golang example(https://github.com/grpc/grpc-go/tree/master/examples/route_guide).
Some time the dart client can't work with golang server, sometime it works, I checked and find out cause the client has not use the secure and the dart server do too.
I want to try fill the option to secure the connection, but I don't know how in dart. And I want to find AES in dart and I failed, so I worry about dart can't work in secure state.

If grpc-dart can work in secure state, could anybody give a demo?

Support secure sockets

Initial implementation only supports TLS (HTTPS) sockets. We should support plain sockets, too.

Bad state: Cannot add event after closing

I got this error when i terminate a client and the client is listening to a Stream.

here is the proto:

syntax = "proto3";

package bug;

import "common.proto";

message Hello {
    string hello = 1;
}

service BugService {
    rpc infiniteStream (common.Empty) returns (stream Hello) {
    }
}

here is the service code :

class BugService extends BugServiceBase {
  final infiniteStreamController = StreamController.broadcast<Hello>();
  int count = 0;

  BugService() {
    Timer.periodic(Duration(seconds: 1), (_) {
      count++;
      infiniteStreamController.add(Hello()..hello = 'Hello $count');
    });
  }

  @override
  Stream<Hello> infiniteStream(ServiceCall call, Empty request) async* {
    await for (final hello in infiniteStreamController.stream) {
      yield hello;
    }
  }
}

and here is the client

Future<void> main() async {
  final channel = ClientChannel(
    'localhost',
    port: 8080,
    options: const ChannelOptions(
      credentials: const ChannelCredentials.insecure(),
    ),
  );
  final client = BugServiceClient(channel);
  final completer = Completer<void>();
  final subscription = client.infiniteStream(Empty()).listen(print);
  ProcessSignal.sigint.watch().listen((_) async {
    await subscription.cancel();
    print('quit gracefully');
    await channel.terminate();
    completer.complete();
  });
  await completer.future;
  exit(0);
}

and here is the stacktrace when the server crash

Unhandled exception:
Bad state: Cannot add event after closing
#0      _StreamController.add (dart:async/stream_controller.dart:584:24)
#1      _StreamSinkWrapper.add (dart:async/stream_controller.dart:858:13)
#2      TransportStream.sendHeaders (package:http2/transport.dart:241:10)
#3      ServerHandler.sendTrailers (package:grpc/src/server/handler.dart:301:13)
#4      ServerHandler._sendError (package:grpc/src/server/handler.dart:350:5)
#5      ServerHandler._onResponse (package:grpc/src/server/handler.dart:239:7)
#6      _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#7      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#8      _DelayedData.perform (dart:async/stream_impl.dart:584:14)
#9      _StreamImplEvents.handleNext (dart:async/stream_impl.dart:700:11)
#10     _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:660:7)
#11     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#12     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#13     _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:391:30)
#14     _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
#15     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)

Question:
How to stop sending value to the stream when the client quit ?

Dart Flutter

Bidireccional stream

0.6.1

Hello, sorry for my english, someone know how to make a duplex connection over exists channel for flutter client-side. This is my code.

ClientChannel _channel;
ClientConnection _connection;
ClientMethod<Q, R> _method;
ClientCall<Q, R> _call;

_channel = new ClientChannel('192.168.0.9',
port: 5001,
options: const ChannelOptions(
credentials: const ChannelCredentials.insecure()));

_method = new ClientMethod<TransportPayloadStringBondEN, ResultDtoBondEN>(
    '/S/m',
    (TransportPayloadStringBondEN value) => value.writeToBuffer(),
    (List<int> value) => new ResultDtoBondEN.fromBuffer(value));

ResponseStream response(Stream request, {CallOptions options}) {
_call = new ClientCall(_method, request, new CallOptions());
_connection.dispatchCall(_call);
return new ResponseStream(_call);
}
startSendAndReciveMessages() async {
if (_connection == null) {
_connection = await _channel.getConnection();
}

var i = new Q();
i.payload = 'START DUPLEX CONNECTION';

Stream<Q> request() async* {
  for (final mess in [i]) {
    // Short delay to simulate some other interaction.
    await new Future.delayed(new Duration(milliseconds: 10));
    print('Sending message ${mess.payload}');
    yield note;
  }
}

final call = response(request());
await for (var res in call) {
  print('Got message ${res.dto.payload}');
}

}

This code create a channel and send one message from the client to the server, the server response one time, and later the call is closed and when I try to send one message from the server over the channel, the server trow an exception "Response stream has already been completed."

" at Grpc.Core.Internal.AsyncCallServer2.CheckSendAllowedOrEarlyResult()\r\n at Grpc.Core.Internal.AsyncCallBase2.SendMessageInternalAsync(TWrite msg, WriteFlags writeFlags)\r\n at Grpc.Core.Internal.ServerResponseStream`2.WriteAsync(TResponse message)\r\n at Test.Communication.gRPC.Server.WinForm.ServerForm.<>c__DisplayClass16_0.<b__0>d.MoveNext() "

The server is c# .NET core.
I try the same with a client winForm, and the channel is keep open, and I can send messages from the server to the client and from the client to server, over the connected channel.

Again, sorry for my very basic english.

Tnks

repeated field generated code is not correct

Step to reproduce

int demo_bug.proto :

syntax = "proto3";

package repros_bug;

message TestMessage {
    repeated string test = 2;
}

then generate the code with :
protoc --dart_out=grpc:lib/src/generated -Iprotos protos/demo_bug.proto

then look at the generated code in lib/src/generated/demo_bug.pb.dart
here is the code

class TestMessage extends GeneratedMessage {
  static final BuilderInfo _i = new BuilderInfo('TestMessage')
    ..pPS(2, 'test')
    ..hasRequiredFields = false
  ;

  TestMessage() : super();
  TestMessage.fromBuffer(List<int> i, [ExtensionRegistry r = ExtensionRegistry.EMPTY]) : super.fromBuffer(i, r);
  TestMessage.fromJson(String i, [ExtensionRegistry r = ExtensionRegistry.EMPTY]) : super.fromJson(i, r);
  TestMessage clone() => new TestMessage()..mergeFromMessage(this);
  BuilderInfo get info_ => _i;
  static TestMessage create() => new TestMessage();
  static PbList<TestMessage> createRepeated() => new PbList<TestMessage>();
  static TestMessage getDefault() {
    if (_defaultInstance == null) _defaultInstance = new _ReadonlyTestMessage();
    return _defaultInstance;
  }
  static TestMessage _defaultInstance;
  static void $checkItem(TestMessage v) {
    if (v is! TestMessage) checkItemFailed(v, 'TestMessage');
  }

  List<String> get test => $_getList(0);
}

As we can see there is no setter for the test field.

Unable to install with Flutter

I am creating a Flutter app, and after the "Hello World" template, I tried installing grpc. I'm unable to install it due to versioning issues. I've tried both with master and beta.

pubspec.lock: none, as I couldn't install

Repro steps

  1. step1: Create Hello World Flutter app in Android Studio
  2. step2: Add gprc to pubspec.yaml
  dependencies:
    flutter:
      sdk: flutter
    grpc: any | or ^0.3.1
  1. step3

$ packages get

Expected result: grpc should install

Actual result: Get an error installing.

Details

I also tried the following variant, as it seemed that dart was only picking up grpc:0.0.1

dependencies:
  flutter:
    sdk: flutter
  grpc:
    git: git://github.com/grpc/grpc-dart.git

Without git repo

Package async has no versions that match ^1.13.3 derived from:
- barback 0.15.2+14 depends on version >=1.10.0 <3.0.0
- flutter_test 0.0.0 depends on version 2.0.4
- glob 1.1.5 depends on version >=1.2.0 <3.0.0
- grpc 0.0.1 depends on version ^1.13.3
- http 0.11.3+16 depends on version >=1.10.0 <3.0.0
- http_multi_server 2.0.4 depends on version >=1.2.0 <3.0.0
- multi_server_socket 1.0.1 depends on version >=1.2.0 <3.0.0
- pool 1.3.4 depends on version >=1.4.0 <3.0.0
- pub itself depends on version >=1.8.0 <3.0.0
- shelf 0.7.2 depends on version >=1.10.0 <3.0.0
- shelf_packages_handler 1.0.3 depends on version >=1.1.0 <3.0.0
- stream_channel 1.6.3 depends on version >=1.11.0 <3.0.0
- test 0.12.30+4 depends on version >=1.13.0 <3.0.0
- watcher 0.9.7+7 depends on version >=1.10.0 <3.0.0
- web_socket_channel 1.0.7 depends on version >=1.3.0 <3.0.0
pub get failed (1)
Process finished with exit code 1

With git repo

Package async has no versions that match ^1.13.3 derived from:
- barback 0.15.2+14 depends on version >=1.10.0 <3.0.0
- flutter_test 0.0.0 depends on version 2.0.4
- glob 1.1.5 depends on version >=1.2.0 <3.0.0
- grpc 0.3.1 depends on version ^1.13.3
- http 0.11.3+16 depends on version >=1.10.0 <3.0.0
- http_multi_server 2.0.4 depends on version >=1.2.0 <3.0.0
- multi_server_socket 1.0.1 depends on version >=1.2.0 <3.0.0
- pool 1.3.4 depends on version >=1.4.0 <3.0.0
- pub itself depends on version >=1.8.0 <3.0.0
- shelf 0.7.2 depends on version >=1.10.0 <3.0.0
- shelf_packages_handler 1.0.3 depends on version >=1.1.0 <3.0.0
- stream_channel 1.6.3 depends on version >=1.11.0 <3.0.0
- test 0.12.30+4 depends on version >=1.13.0 <3.0.0
- watcher 0.9.7+7 depends on version >=1.10.0 <3.0.0
- web_socket_channel 1.0.7 depends on version >=1.3.0 <3.0.0
pub get failed (1)
Process finished with exit code 1

NoSuchMethodError: The method '&' was called on null.

I'm trying to stream a image file to a grpc server using 1KB chunks

As soon as I get the File on dart, I convert it to a Stream

Stream<ImageRequest> chunkFileBytes(List<int> stream) async* {
  List<int> buffer = new List<int>(1024);
  var counter = 0;
  print("Total bytes: ${stream.length}");
  for (var i = 0; i < stream.length; i++) {
    buffer[counter] = stream[i];
    counter++;
    if (counter == 1024) {
      var req = new ImageRequest();
      req.content = buffer;
      counter = 0;
      buffer = new List<int>(1024);
      yield req;
    }
    if (counter > 0) {
      var req = new ImageRequest();
      req.content = buffer;
      yield req;
    }
  }
}

and pass this to grpc

var bytes = image.readAsBytesSync();
final post = await stub.postImage(chunkFileBytes(bytes));

But that's throwing error

gRPC Error (2, NoSuchMethodError: The method '&' was called on null.
Receiver: null
Tried calling: &(255))
#0      _FeedScreen.getImage (package:myapp/feed.dart:71:18)
<asynchronous suspension>

I'm suspecting something is trying to use the very first byte of the first chunk of my stream as a function and that's blowing up.

Using
grpc: "^0.4.1"

Build failures

Last few builds have failed in master, for example:
https://travis-ci.org/grpc/grpc-dart/builds/397966375

00:08 +22 -1: test/client_test.dart: Unary calls work on the client [E]                                                                                                                                
  Invalid argument(s): A typed argument was passed in as a named argument named "Symbol("endStream")", but did not pass a value for `named`. Each typed argument that is passed as a named argument needs to specify the `named` argument. For example: `when(obj.fn(x: typed(any, named: "x")))`.
  package:mockito/src/mock.dart 211:11  _InvocationForTypedArguments._reconstituteNamedArgs.<fn>
  dart:collection                       MapView.forEach
  package:mockito/src/mock.dart 206:31  _InvocationForTypedArguments._reconstituteNamedArgs
  package:mockito/src/mock.dart 179:26  new _InvocationForTypedArguments
  package:mockito/src/mock.dart 148:22  _useTypedInvocationIfSet
  package:mockito/src/mock.dart 105:18  Mock.noSuchMethod
  package:http2/transport.dart 186:25   MockTransport.makeRequest
  test/src/client_utils.dart 126:20     ClientHarness.setUp
  test/client_test.dart 31:36           main.<fn>
  
  NoSuchMethodError: The method 'tearDown' was called on null.
  Receiver: null
  Tried calling: tearDown()
  dart:core                    Object.noSuchMethod
  test/client_test.dart 35:13  main.<fn>
  
00:09 +22 -2: test/client_test.dart: Client-streaming calls work on the client [E]                                                                                                                     
  Invalid argument(s): A typed argument was passed in as a named argument named "Symbol("endStream")", but did not pass a value for `named`. Each typed argument that is passed as a named argument needs to specify the `named` argument. For example: `when(obj.fn(x: typed(any, named: "x")))`.
  package:mockito/src/mock.dart 211:11  _InvocationForTypedArguments._reconstituteNamedArgs.<fn>
  dart:collection                       MapView.forEach
  package:mockito/src/mock.dart 206:31  _InvocationForTypedArguments._reconstituteNamedArgs
  package:mockito/src/mock.dart 179:26  new _InvocationForTypedArguments
  package:mockito/src/mock.dart 148:22  _useTypedInvocationIfSet
  package:mockito/src/mock.dart 105:18  Mock.noSuchMethod
  package:http2/transport.dart 186:25   MockTransport.makeRequest
  test/src/client_utils.dart 126:20     ClientHarness.setUp
  test/client_test.dart 31:36           main.<fn>
  
  NoSuchMethodError: The method 'tearDown' was called on null.
  Receiver: null
  Tried calling: tearDown()
  dart:core                    Object.noSuchMethod
  test/client_test.dart 35:13  main.<fn>
  
  ...

support for http

does the package support http ?

syntax = "proto3";
package example;

import "google/api/annotations.proto";

message StringMessage {
  string value = 1;
}
 
service YourService {
  rpc Echo(StringMessage) returns (StringMessage) {
    option (google.api.http) = {
      post: "/v1/example/echo"
      body: "*"
    };
  }
}

gRPC Error Codes final vs const

The gRPC error codes are defined here:

class StatusCode {
/// The operation completed successfully.
static final ok = 0;
/// The operation was cancelled (typically by the caller).
static final cancelled = 1;
/// Unknown error. An example of where this error may be returned is if a
/// Status value received from another address space belongs to an error-space
/// that is not known in this address space. Also errors raised by APIs that
/// do not return enough error information may be converted to this error.
static final unknown = 2;
/// Client specified an invalid argument. Note that this differs from
/// [failedPrecondition]. [invalidArgument] indicates arguments that are
/// problematic regardless of the state of the system (e.g., a malformed file
/// name).
static final invalidArgument = 3;
/// Deadline expired before operation could complete. For operations that
/// change the state of the system, this error may be returned even if the
/// operation has completed successfully. For example, a successful response
/// from a server could have been delayed long enough for the deadline to
/// expire.
static final deadlineExceeded = 4;
/// Some requested entity (e.g., file or directory) was not found.
static final notFound = 5;
/// Some entity that we attempted to create (e.g., file or directory) already
/// exists.
static final alreadyExists = 6;
/// The caller does not have permission to execute the specified operation.
/// [permissionDenied] must not be used for rejections caused by exhausting
/// some resource (use [resourceExhausted] instead for those errors).
/// [permissionDenied] must not be used if the caller cannot be identified
/// (use [unauthenticated] instead for those errors).
static final permissionDenied = 7;
/// Some resource has been exhausted, perhaps a per-user quota, or perhaps the
/// entire file system is out of space.
static final resourceExhausted = 8;
/// Operation was rejected because the system is not in a state required for
/// the operation's execution. For example, directory to be deleted may be
/// non-empty, an rmdir operation is applied to a non-directory, etc.
///
/// A litmus test that may help a service implementor in deciding between
/// [failedPrecondition], [aborted], and [unavailable]:
/// (a) Use [unavailable] if the client can retry just the failing call.
/// (b) Use [aborted] if the client should retry at a higher-level (e.g.,
/// restarting a read-modify-write sequence).
/// (c) Use [failedPrecondition] if the client should not retry until the
/// system state has been explicitly fixed. E.g., if an "rmdir" fails
/// because the directory is non-empty, [failedPrecondition] should be
/// returned since the client should not retry unless they have first
/// fixed up the directory by deleting files from it.
static final failedPrecondition = 9;
/// The operation was aborted, typically due to a concurrency issue like
/// sequencer check failures, transaction aborts, etc.
///
/// See litmus test above for deciding between [failedPrecondition],
/// [aborted], and [unavailable].
static final aborted = 10;
/// Operation was attempted past the valid range. E.g., seeking or reading
/// past end of file.
///
/// Unlike invalidArgument, this error indicates a problem that may be fixed
/// if the system state changes. For example, a 32-bit file system will
/// generate invalidArgument if asked to read at an offset that is not in the
/// range [0,2^32-1], but it will generate [outOfRange] if asked to read from
/// an offset past the current file size.
///
/// There is a fair bit of overlap between [failedPrecondition] and
/// [outOfRange]. We recommend using [outOfRange] (the more specific error)
/// when it applies so that callers who are iterating through a space can
/// easily look for an [outOfRange] error to detect when they are done.
static final outOfRange = 11;
/// Operation is not implemented or not supported/enabled in this service.
static final unimplemented = 12;
/// Internal errors. Means some invariants expected by underlying system has
/// been broken. If you see one of these errors, something is very broken.
static final internal = 13;
/// The service is currently unavailable. This is a most likely a transient
/// condition and may be corrected by retrying with a backoff.
///
/// See litmus test above for deciding between [failedPrecondition],
/// [aborted], and [unavailable].
static final unavailable = 14;
/// Unrecoverable data loss or corruption.
static final dataLoss = 15;
/// The request does not have valid authentication credentials for the
/// operation.
static final unauthenticated = 16;
}

Is there a reason why these error codes are marked as final rather than const? They seem pretty constant to me, and I was hoping to use the values in a switchstatement.

can't get anything to build

Keep getting this:
Your package must have a "web" directory,
or you must specify the source directories.

What am I doing wrong?
dart 1.24.2

Flutter app with grpc-dart, fails with flutter_test: "Package hrpc has no versions that match 0.3.1

When trying to use grpc dart in my flutter app im keep getting the following error:

`
Running "flutter packages get" in boomrang_app...
Package async has no versions that match 2.0.4 derived from:

  • boomrang_app depends on version ^1.13.3
  • flutter_test 0.0.0 depends on version 2.0.4
  • grpc 0.3.1 depends on version ^1.13.3
  • http 0.11.3+16 depends on version >=1.10.0 <3.0.0
    `

I can resolve it by removing my dev_dependencies from the following pubspec.yaml file:

pubspec.yaml:

`name: boomrang_app
description: Boomrang mobile app

environment:
sdk: '>=1.24.3 <2.0.0'

dependencies:
flutter:
sdk: flutter
contact_picker: "^0.0.1+2"

The following adds the Cupertino Icons font to your application.

Use with the CupertinoIcons class for iOS style icons.

cupertino_icons: ^0.1.0
grpc: "^0.3.1"
protobuf: ^0.7.0

async: ^1.13.3

dev_dependencies:
test: ^0.12.0
flutter_test:
sdk: flutter
`

Also why do i need to specify the async dependecies ? And can i remove the "test: 0.12.0" dependency in the dev_depencies?

Anyway removing dev_dependecies resolves it, but thats not a proper solution.

does not work properly on windows 10 protoc-gen-dart: The system cannot find the specified file.

protoc-gen-dart: The system cannot find the specified file.

0.7.10

Repro steps

  1. install pub global activate protoc_plugin
  2. protoc-gen-dart, is installed in %PATH%
  3. protoc --dart_out=grpc:. -I.

Expected result: it should convert my IDL, generate the classes in Dart.

Actual result: --dart_out: protoc-gen-dart: The system cannot find the specified file.

Details

Dart version
Dart VM version: 2.0.0-dev.28.0.flutter-0b4f01f759 (Tue Feb 20 17:53:06 2018 +0000) on "windows_x64"
Windows 10

Thanks!

Dart2 runtime failures in tests

running tests in dart 2 mode, see failures like

type 'ArgMatcher' is not a subtype of type 'List

' where...
type 'ArgMatcher' is not a subtype of type 'List' where
ArgMatcher is from package:mockito/src/mock.dart
List is from dart:core
Header is from package:http2/src/hpack/hpack.dart
../../dart/grpc/test/src/client_utils.dart 126:32 ClientHarness.setUp

Add logger for debugging

It would be really great if this package would use a (logging-compliant) logger that could be set to get better reporting when things go wrong.

The method 'remove' was called on null.

grpc with latest version from pub.

i got this error sometimes but not sure right now how to reproduce exactly.

Unhandled exception:
NoSuchMethodError: The method 'remove' was called on null.
Receiver: null
Tried calling: remove(":status")
#0      Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:46:5)
#1      ServerHandler.sendTrailers (package:grpc/src/server/handler.dart:286:23)
#2      ServerHandler._sendError (package:grpc/src/server/handler.dart:350:5)
#3      ServerHandler._onResponse (package:grpc/src/server/handler.dart:239:7)
#4      _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#5      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#6      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#7      _SyncStreamController._sendData (dart:async/stream_controller.dart:763:19)
#8      _StreamController._add (dart:async/stream_controller.dart:639:7)
#9      new Stream.fromFuture.<anonymous closure> (dart:async/stream.dart:107:18)
#10     _RootZone.runUnary (dart:async/zone.dart:1379:54)
#11     _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
#12     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:642:45)
#13     Future._propagateToListeners (dart:async/future_impl.dart:671:32)
#14     Future._complete (dart:async/future_impl.dart:476:7)
#15     _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
#16     _completeOnAsyncReturn (dart:async/runtime/libasync_patch.dart:292:13)
#17     IngredientService.search (package:backend/src/services/ingredient/ingredient.dart)
<asynchronous suspension>
#18     IngredientServiceBase.search_Pre (package:protos/src/generated/ingredient.pbgrpc.dart:139:12)
<asynchronous suspension>
#19     ServiceMethod.handle (package:grpc/src/server/service.dart:63:20)
#20     ServerHandler._startStreamingRequest (package:grpc/src/server/handler.dart:153:30)
#21     ServerHandler._onDataIdle (package:grpc/src/server/handler.dart:129:5)
#22     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#23     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#24     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#25     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)
#26     _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
#27     grpcDecompressor.<anonymous closure> (package:grpc/src/shared/streams.dart:54:12)
#28     _HandlerEventSink.add (dart:async/stream_transformers.dart:236:7)
#29     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)
#30     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#31     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#32     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#33     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)
#34     _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
#35     _GrpcMessageConversionSink._addHeaders (package:grpc/src/shared/streams.dart:163:10)
#36     _GrpcMessageConversionSink.add (package:grpc/src/shared/streams.dart:171:7)
#37     _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:86:18)
#38     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)
#39     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#40     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#41     _DelayedData.perform (dart:async/stream_impl.dart:584:14)
#42     _StreamImplEvents.handleNext (dart:async/stream_impl.dart:700:11)
#43     _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:660:7)
#44     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#45     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#46     _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:113:13)
#47     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:166:5)

Handshake fails with Go gRPC server (EOF)

I have a Golang gRPC server daemon: https://github.com/btcsuite/btcwallet
And I created a Dart RPC client package for it (utility): https://github.com/stevenroose/dart-btcwallet-rpc

I'm trying to make them connect as follows (btcwallet generates a certificate file for localhost):

var certFile = new File("/home/steven/.btcwallet/rpc.cert");
var cert = await certFile.readAsBytes();
var rpcUri = Uri.parse("https://localhost:9090");

_grpcChannel = new ClientChannel(rpcUri.host, port: rpcUri.port,
  options: new ChannelOptions.secure(certificate: rpcCertificate));
_grpcWalletService = new WalletServiceClient(_grpcChannel);

Calling any of the methods of _grpcWalletService returns in the following error on the server while I can't catch any exceptions on the server.

Server.Serve failed to complete security handshake from "127.0.0.1:58620": EOF

The system can't find the specified file

Operation based on document hints
I'm using windows10, to prompt errors when using the protoc tool to generate dart files

step 1:
pub global activate protoc_plugin

step 2: add to PATH :
image

error info:
image

error message (translate): The system can't find the specified file

Failed to generate the grpc code for Dart --dart_out: protoc-gen-dart: Plugin failed with status code 252.

I follow the instruction to download and install protoc and protoc plugin for dart here.
I use Linux
protoc version 3.6.0

I could not generate the code for dart and this error message came out:
--dart_out: protoc-gen-dart: Plugin failed with status code 252.
and
Crash when compiling file:///home/phat/.pub-cache/global_packages/protoc_plugin/bin/protoc_plugin.dart.snapshot, at character offset null: String starting with ' must end with '. #0 ErrorToken.lexeme (package:front_end/src/fasta/scanner/error_token.dart:74:24) #1 _withArgumentsExpectedDeclaration (file:///tmp/tmpcU3f4j/dart-2.0.0-dev.64.1/dart/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart:1989:25) #2 Parser.reportRecoverableErrorWithToken (package:front_end/src/fasta/parser/parser.dart:6020:20)

Thank you!

failed with flutter test:call from the client against the fake server, and verify behaviors changes from the server side

I want to write fake server for test client, and I follow examples in test/client_test.dart but Request and Response type not int and I got this error:
type 'LoginResp' is not a subtype of type 'StreamMessage'. how to send data to mock channel and get its response?

  test('login request', () async {

    var loginReq = new LoginReq();
    loginReq.serverAddr = '127.0.01';
    loginReq.imei = 350..;
    loginReq.language = 'EN';
    loginReq.password = 'Password';
    loginReq.userName = 'UserName';

    var loginResp = new LoginResp();
    loginResp.token = 'Token';
    loginResp.success = true;

    void handleRequest(StreamMessage message) {

      harness
        ..sendResponseHeader()
        ..sendResponseValue(loginResp)
        ..sendResponseTrailer();
    }

    await harness.runTest(
      clientCall: harness.userClient.login(loginReq),
      expectedResult: loginResp,
      expectedPath: 'messages.User/Login',
      serverHandlers: [handleRequest],
    );
  });

and I changed function of sendResponseValue

 void sendResponseValue(var value) {
    toClient
//        .add(new DataStreamMessage(GrpcHttpEncoder.frame(mockEncode(value))));

        .add(value);
  }

Add support for proxies

Since it's super annoying to debug network protocols without running them through Charles.

Should respect http_proxy environment variable (and friends).

Feature Request: Client Interceptors

It looks like the implemented interceptors are only server interceptors. Is it possible to create client interceptors?

I need to intercept calls that I make from a Flutter application and add authentication metadata

Using v 0.6.4

Repro steps

None

Details

I don't think this would need a gRFC, as I presume a general one exists since Java has client interceptors
.

package import statement generated with well-defined type is not correct.

When compiling using the following command, the import statement is not Dart code. Are there any examples for how to handle this - thank you!

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

  grpc:
    dependency: "direct main"
    description:
      name: grpc
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.4.0"

Repro steps

  1. Run: protoc -Iprotos -I $(GOPATH)src/github.com/golang/protobuf/ptypes/timestamp --dart_out=grpc:proto_out/service.proto

Expected result: Usable dart import package declaration for the well-defined types

Actual result: package import declaration causes an error and compilation is not possible.

Details

Below is a snipped of the .proto file. I am trying to create a client stub (the server is written in Go). I have confirmed the client stub exported from Go works.

syntax = "proto3";

package mypackage;

option go_package = "github.com/mypackage;

import "google/protobuf/timestamp.proto";

message Timestamp {
    google.protobuf.Timestamp created = 1;
    google.protobuf.Timestamp updated = 2;
    google.protobuf.Timestamp synced = 3;
}
... implementation details to follow...

Upon running the protoc command the output is:

/// service.pb.dart

///
//  Generated code. Do not modify.
///
// ignore_for_file: non_constant_identifier_names,library_prefixes
library my_service;

// ignore: UNUSED_SHOWN_NAME
import 'dart:core' show int, bool, double, String, List, override;

import 'package:protobuf/protobuf.dart';

import 'google/protobuf/timestamp.pb.dart' as $google$protobuf;

import 'service.pbenum.dart';

export 'service.pbenum.dart';

/// ...generated code continues...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.