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
- 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
- Create implementation of DaprClientBase where on OnInvoke you receive HelloRequest and return HelloResponce objects.
- Create ASP.NET Core console application, generate client classes from daprclient.proto (Client only), generate client classes from greet.proto (Client only)
- 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);
- 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)
@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!