0
Hallo alle Ich versuche, Verbindung zu STOMP Endpunkt in Spring Start-App und bekomme diesen Fehler, wenn ich jemals mit STOMP.js und Socke verbinden jsGetting error "Fehler beim Parsen von TextMessage Nutzlast = [CONNECT" in STOMP während der Verbindung t
o.s.w.s.m.StompSubProtocolHandler : Failed to parse TextMessage payload=[CONNECT
ac..], byteCount=523, last=true] in session b9ql5g3w. Sending STOMP ERROR to client.
org.springframework.messaging.simp.stomp.StompConversionException: Illegal header: ' setConnected(true);'. A header must be of the form <name>:[<value>].
at org.springframework.messaging.simp.stomp.StompDecoder.readHeaders(StompDecoder.java:224) ~[spring-messaging-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.messaging.simp.stomp.StompDecoder.decodeMessage(StompDecoder.java:138) ~[spring-messaging-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.messaging.simp.stomp.StompDecoder.decode(StompDecoder.java:111) ~[spring-messaging-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.messaging.simp.stomp.BufferingStompDecoder.decode(BufferingStompDecoder.java:133) ~[spring-messaging-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.socket.messaging.StompSubProtocolHandler.handleMessageFromClient(StompSubProtocolHandler.java:234) ~[spring-websocket-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.socket.messaging.SubProtocolWebSocketHandler.handleMessage(SubProtocolWebSocketHandler.java:307) [spring-websocket-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.socket.handler.WebSocketHandlerDecorator.handleMessage(WebSocketHandlerDecorator.java:75) [spring-websocket-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at 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]
at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.delegateMessages(AbstractSockJsSession.java:385) [spring-websocket-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at ..............................................................
und mein JavaScript-Code ist
function connect() {
var socket = new SockJS('/hello');
stompClient = Stomp.over(socket);
stompClient.connect({}, function(frame) {
setConnected(true);
console.log('Connected: ' + frame);
stompClient.subscribe('/topic/Presence', function(greeting){
console.log(greeting.body);
showGreeting(JSON.parse(greeting.body).userId,JSON.parse(greeting.body).status,JSON.parse(greeting.body).imageUrl);
});
});
}
ich auch Sicherheitsfederverschluß verwenden. und meine Websocket Config und endpont sind
@MessageMapping("/hello")
@SendTo("/topic/Presence")
public UserPresences greeting(String message) throws Exception {
Thread.sleep(1000); // simulated delay
return new UserPresences();
}
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableSimpleBroker("/topic");
config.setApplicationDestinationPrefixes("/app");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/hello").withSockJS();
}
}
ich ein ähnliches Problem haben, Zahid vielleicht haben Sie es auch gehabt? https://stackoverflow.com/questions/42092662/failed-to-parse-textmessage-payload-unsubscrib – lanx