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.

Grpc parsing json formated string

See original GitHub issue

I have a class that is Json serialized but on the server it shows an error.

My question is, Why is Grpc not treating string as string. If the DataStatus class does not have the Status property it works.

Microsoft Visual Studio Community 2019 Version 16.11.8 Grpc.AspNetCore 2.41.0

[11:34:08.657  DBG][0HME4VFKP1S26:00000001] Grpc.AspNetCore.Server.ServerCallHandler: Reading message.
[11:34:08.659  INF][0HME4VFKP1S26:00000001] Grpc.AspNetCore.Server.ServerCallHandler: Error reading message.
Grpc.Core.RpcException: Status(StatusCode="Internal", Detail="Incomplete message.")
   at Grpc.AspNetCore.Server.Internal.PipeExtensions.ReadSingleMessageAsync[T](PipeReader input, HttpContextServerCallContext serverCallContext, Func`2 deserializer)
[11:34:08.715  INF][0HME4VFKP1S26:00000001] Grpc.AspNetCore.Server.ServerCallHandler: Error status code 'Internal' with detail 'Incomplete message.' raised.
// protos
message AlertMessage {
	string id = 1;
	string command = 2;
	string message = 3;
	string type = 4;
}
//c#

string message = JsonSerializer.Serialize(new DataStatus { SerialNo = "12334", Status = updateStatus });
await _grpc.AlertAsync(new AlertMessage { Id = id.ToString(), Command = "ReceiveNewData", Message = message, Type = "update" });

//
public class UpdateStatus
{
   public string Status {get;set;} = "Done"
   public DateTime UpdateDateTime {get;set;} = DateTime.Now;
}
public class DataStatus
{
  public string SerialNo {get;set;}="";
  public UpdateStatus Status {get;set;} = new();

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
JamesNKcommented, Dec 23, 2021

It shouldn’t matter that there is a JSON string.

Could you upload a reproduction of the problem? I will take a look.

0reactions
JamesNKcommented, Jan 13, 2022

Hi. We’re closing this issue as we have heard no response from you for some time now. If you have more details and are encountering this issue please add a new reply and re-open the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

gRPC + JSON
Gson is a popular library for Java for doing JSON encoding. Let's remove all the protobuf related things and replace them with Gson:....
Read more >
Using gRPC with JSON
Using gRPC with JSON ... It's often said that gRPC is tied to the Google Protocol Buffers payload format, but this is not...
Read more >
Convert between JSON and Protobuf
We can convert JSON to a protobuf message by using JsonFormat. JsonFormat is a utility class to convert protobuf messages to/from JSON format....
Read more >
How to convert from Json to Protobuf?
With proto3 you can do this using JsonFormat. It parses directly from the JSON representation, so there is no need for separately calling ......
Read more >
Google.Protobuf.JsonParser Class Reference
Returns a formatter using the default settings. Public functions. Parse(string json, MessageDescriptor descriptor). IMessage. Parses ...
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