Sending protobuf serialized object from c# to java server not working? -


I have a simple C # client app that sends objects to the Java based server app. Note: I am using ProtoBuff-Net on the Clint Side. Simple to this application I have. Proto file is only one field and. The Javascript is generated by the Protocol compiler with the Java class.

.profo file:

  message person {required string id = 1; }   

C # client to send objects

  MemoryStream ms = new MemoryStream (); Per person = new person (); Per.id = "TestId001"; Serializer.Serialize & lt; Person & gt; (MS, copy); Byte [] Buffer = MS ToArray (); ClientSocket.SendTo (buffer, host app);    Person person = purse Parsfram (socket.getInputStream ()); System.out.println ("id:" + person.getId ());   

Problem: A serialized message sent by C #Ap is not available. Even I have not got any error, that is why I am unable to assess the problem.

"Problem: I can not find the serialized message" / p>

Em> sound is just like the classic "socks stams" problem (second example here :). If you have written data in any stream but have not closed the stream, then the stream that is does not end also does not automatically know that the client has sent 117 bytes (say to say) Which should be considered a message. You have two options:

  • Close the outbound stream after typing (only suitable for sending a single message, not for continuous discussion between two nodes)
  • Introducing some form framing - for example a length prefix - so that the receiver should know that instead of trying to read the eof, try to read only certain data (which will never come if You have not closed it outbound Note: In addition to the problem "sockets are stams", keep in mind that Protoboof messaging attachments are a protocol message, by itself, it has no assumptions Where it ends Fortunately, the above mentioned bullet points will both focus on this. But importantly, you can not write 3 person objects in the stream (or stream closed) in one frame, and then hope to be able to get 3 person Object on the other end: You will find a person object in this scenario, the easiest option is to add the cover object, i.e. SomeMessage {double person people = 1; }

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -