下面是我的WebSocketStompClient和protobuf示例
message PushHeader {
double id = 1;
string first_name = 2;
string last_name = 3;
}
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
container.setDefaultMaxTextMessageBufferSize(10*1024*1024);
container.setDefaultMaxBinaryMessageBufferSize(10*1024 * 1024);
WebSocketClient webSocketClient = new StandardWebSocketClient(container);
WebSocketStompClient stompClient = new WebSocketStompClient(webSocketClient);
stompClient.setMessageConverter(new ByteArrayMessageConverter());
stompClient.setInboundMessageSizeLimit(Integer.MAX_VALUE);
每当我尝试发送包含Protobuf(PushHeader.toByteArray())的byte []时。我继续在下面得到这个错误。我注意到这只发生在我填写id字段时。如果我把它留空,那么它就会通过。我假设int64和双打没有正确转换。
作品
PushMessageProto.PushHeader r = PushMessageProto.PushHeader.newBuilder().setFirstName("df").setLastName("R").build();
不起作用
PushMessageProto.PushHeader r = PushMessageProto.PushHeader.newBuilder().setFirstName("d").setLastName("R").setId(1).build();
有谁知道我应该选择哪个方向?
org.springframework.messaging.simp.stomp.StompConversionException:帧必须以null八位字节终止 在org.springframework.messaging.simp.stomp.StompDecoder.readPayload(StompDecoder.java:301)〜[spring-messaging-4.2.5.RELEASE.jar:4.2.5.RELEASE] 在org.springframework.messaging.simp.stomp.StompDecoder.decodeMessage(StompDecoder.java:139)〜[spring-messaging-4.2.5.RELEASE.jar:4.2.5.RELEASE] 在org.springframework.messaging.simp.stomp.StompDecoder.decode(StompDecoder.java:111)〜[spring-messaging-4.2.5.RELEASE.jar:4.2.5.RELEASE] 在org.springframework.messaging.simp.stomp.BufferingStompDecoder.decode(BufferingStompDecoder.java:133)〜[spring-messaging-4.2.5.RELEASE.jar:4.2.5.RELEASE] 在org.springframework.web.socket.messaging.StompSubProtocolHandler.handleMessageFromClient(StompSubProtocolHandler.java:234)〜[spring-websocket-4.2.5.RELEASE.jar:4.2.5.RELEASE] 在org.springframework.web.socket.messaging.SubProtocolWebSocketHandler.handleMessage(SubProtocolWebSocketHandler.java:307)[spring-websocket-4.2.5.RELEASE.jar:4.2.5.RELEASE] 在org.springframework.web.socket.handler.WebSocketHandlerDecorator.handleMessage(WebSocketHandlerDecorator.java:75)[spring-websocket-4.2.5.RELEASE.jar:4.2.5.RELEASE] 在org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator.handleMessage(LoggingWebSocketHandlerDecorator.java:56)[spring-websocket-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.web.socket.handler.ExceptionWebSocketHandlerDecorator.handleMessage(ExceptionWebSocketHandlerDecorator.java:58)[spring-websocket-4.2.5.RELEASE.jar:4.2.5.RELEASE] 在org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.handleTextMessage(StandardWebSocketHandlerAdapter.java:110)[spring-websocket-4.2.5.RELEASE.jar:4.2.5.RELEASE] 在org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.access $ 000(StandardWebSocketHandlerAdapter.java:42)[spring-websocket-4.2.5.RELEASE.jar:4.2.5.RELEASE] 在org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter $ 3.onMessage(StandardWebSocketHandlerAdapter.java:81)[spring-websocket-4.2.5.RELEASE.jar:4.2.5.RELEASE] 在org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter $ 3.onMessage(StandardWebSocketHandlerAdapter.java:78)[spring-websocket-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.apache.tomcat.websocket.WsFrameBase.sendMessageText(WsFrameBase.java:375)[tomcat-embed-websocket-8.0.3.jar:8.0.3] at org.apache.tomcat.websocket.WsFrameBase.processDataText(WsFrameBase.java:472)[tomcat-embed-websocket-8.0.3.jar:8.0.3] at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:275)[tomcat-embed-websocket-8.0.3.jar:8.0.3] at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:116)[tomcat-embed-websocket-8.0.3.jar:8.0.3] at org.apache.tomcat.websocket.server.WsFrameServer.onDataAvailable(WsFrameServer.java:55)[tomcat-embed-websocket-8.0.3.jar:8.0.3] at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler $ WsReadListener.onDataAvailable(WsHttpUpgradeHandler.java:194)[tomcat-embed-websocket-8.0.3.jar:8.0.3] 在org.apache.coyote.http11.upgrade.AbstractServletInputStream.onDataAvailable(AbstractServletInputStream.java:184)[tomcat-embed-core-8.0.3.jar:8.0.3] at org.apache.coyote.http11.upgrade.AbstractProcessor.upgradeDispatch(AbstractProcessor.java:95)[tomcat-embed-core-8.0.3.jar:8.0.3] at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:650)[tomcat-embed-core-8.0.3.jar:8.0.3] 在org.apache.coyote.http11.Http11NioProtocol $ Http11ConnectionHandler.process(Http11NioProtocol.java:222)[tomcat-embed-core-8.0.3.jar:8.0.3] 在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1575)[tomcat-embed-core-8.0.3.jar:8.0.3] 在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.run(NioEndpoint.java:1533)[tomcat-embed-core-8.0.3.jar:8.0.3] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[na:1.8.0_66] at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)[na:1.8.0_66] 在java.lang.Thread.run(Thread.java:745)[na:1.8.0_66]