2016-04-08 6 views
0

STOMPエンドポイントに接続しようとしましたが、STOMP.jsとsock .jsファイルエラーを取得しています "TextMessageのペイロードを解析できませんでした=接続中にSTOMPの[CONNECT]

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 .............................................................. 

と私のjavasciptコードは、私はまた、春のブートセキュリティを使用しています

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); 

       }); 
      }); 
     } 

です。そして私のWebSocketのコンフィグとendpontが

@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(); 
    } 

} 
+0

にコードを変更することで、私の問題をsloveすることができた、Zahidは多分あなたもそれを持っていましたか? https://stackoverflow.com/questions/42092662/failed-to-parse-textmessage-payload-unsubscrib – lanx

答えて

1

ている私は、私は同様の問題を抱えているクライアント側

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); 

       }); 
      }); 
     } 
関連する問題