DaprClient via gRPC: problem with object serialization
See original GitHub issueExpected 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
Issue Analytics
- State:
- Created 3 years ago
- Comments:26 (9 by maintainers)
Top Results From Across the Web
DaprClient usage
Many methods on DaprClient perform JSON serialization using the System.Text.Json serializer. Methods that accept an application data type as an argument ...
Read more >Serialization in Dapr's SDKs
In this case, the object is serialized to byte[] as well and the input binding receives the raw byte[] as-is and deserializes it...
Read more >The Dapr service invocation building block
In the example above, DaprClient serializes the given order object using Protobuf and uses the result as the gRPC request body. Likewise, the ......
Read more >Another downside in gRPC is that (de)serialization can be ...
Another downside in gRPC is that (de)serialization can be relatively slow. One of my pet projects is a tagging server that takes a...
Read more >Invoking Dapr Services in Azure Container Apps using gRPC
I'm calling “Unpack” and specifying the expected input type request to serialize the data into a strongly typed object. Using the injected “ ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub 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.