On Mon, 26 Aug 2013 17:32:23 -0700 (PDT)
chrisg...@gmail.com wrote:

> Thanks for taking the time to read/reply.
> 
> GetHeartbeat2 is my original version which I included as well and the
> way I had thought it should probably work. This code is serializing
> to string
> on the inner buffer and then again on the outer.  
> 
>    response.response_proto = heartbeatResult.SerializeToString()
>     self.sendMessage(response.SerializeToString())
> 
> 
> The GetHeartbeat2 generates this error on the server ( I included
> more of the stack trace this time)
> Message: [org.java_websocket.exceptions.InvalidDataException: 
> java.nio.charset.MalformedInputException: Input length = 1
>     at 
> org.java_websocket.util.Charsetfunctions.stringUtf8(Charsetfunctions.java:80)
>     at 
> org.java_websocket.WebSocketImpl.deliverMessage(WebSocketImpl.java:561)
>     at
> org.java_websocket.WebSocketImpl.decodeFrames(WebSocketImpl.java:328)
> at org.java_websocket.WebSocketImpl.decode(WebSocketImpl.java:149) at 
> org.java_websocket.server.WebSocketServer$WebSocketWorker.run(WebSocketServer.java:593)
> Caused by: java.nio.charset.MalformedInputException: Input length = 1
>     at
> java.nio.charset.CoderResult.throwException(CoderResult.java:277) at
> java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:798) at 
> org.java_websocket.util.Charsetfunctions.stringUtf8(Charsetfunctions.java:77)
> 

This stack trace suggests you’re still involving UTF-8 somewhere, this
time on the Java side (java.nio.charset, stringUtf8 method name, etc.).
Again, an encoded Protobuf message is a BYTE STRING. You should not be
doing UTF-8 things, or any other text-related things, to it. I have no
idea how Websockets work, but if they are not capable of transporting
byte strings directly (if they only carry text, for example), then you
will have to do further encoding on your Protobuf message—Base64 might
be suitable here.

Chris

Attachment: signature.asc
Description: PGP signature

Reply via email to