question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DaprClient via gRPC: problem with object serialization

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:26 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
GennadiiSvichinskyicommented, Jun 3, 2020

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

1reaction
GennadiiSvichinskyicommented, Jun 2, 2020

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found