Grpc parsing json formated string
See original GitHub issueI 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:
- Created 2 years ago
- Comments:7 (5 by maintainers)
Top 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 >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
It shouldn’t matter that there is a JSON string.
Could you upload a reproduction of the problem? I will take a look.
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.