dotnet-sdk: DaprClient via gRPC: problem with object serialization

Expected Behavior

InvokeMethodAsync returns deserialized HelloReply object

Actual Behavior

Unhandled exception. System.Text.Json.JsonException: '0x13' is an invalid start of a value. Path: $ | LineNumber: 1 | BytePositionInLine: 0.

Steps to Reproduce the Problem

  1. Create gRPC service with ASP.NET Core 3.1 (in VS 2019 it will be created with Greeter service sample), generate client classes from daprclient.proto (Service only). It also require darp.proto classes generation
  2. Create implementation of DaprClientBase where on OnInvoke you receive HelloRequest and return HelloResponce objects.
  3. Create ASP.NET Core console application, generate client classes from daprclient.proto (Client only), generate client classes from greet.proto (Client only)
  4. Add reference on Dapr.Client package, create dapr client and call InvokeMethodAsync against gRPC service. Something like var msg = new HelloRequest() {Name = "Gennadii"}; var anyReply = await client.InvokeMethodAsync<HelloRequest, HelloReply>("testGrpcDapr", "SayHello", msg);
  5. Start both apps via Dapr with grpc protocol (I used standalone mode).

Test project attached. (there is a workaround there which is commented out there) TestGrpcWithDapr.zip

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 26 (9 by maintainers)

Commits related to this issue

Most upvoted comments

@jjindrich, right. 😃 I’ve updated the solution with invoking existing GreeterService.

@jjindrich you shouldn’t run from ‘bin’ folders with ‘dotnet run’. Go to the folder with .csproj file and run from there. Both server and client. I think that’s the core of your problem.

@GennadiiSvichinskyi many thanks for sharing demo ! If I good understand, when calling with dapr, on server side is not used GreeterService.SayHello method, correct ?

Where is GreeterBase coming from - the proto files? <<EDIT - Never mind I got over being lazy, downloaded it, compiled and confirmed my own suspicion! I’m reminded again why we do open source!

Hi @jjindrich , I’ve a little bit updated it to DAPR 0.71 and put to here. Hopefully, it will help you )