Stomp over socket using sockjs can't connect with Spring 4 WebSocket

前端 未结 4 2067
南方客
南方客 2020-12-06 13:51

Trying to use Spring 4 WebSocket with STOMP over socket using sockjs. And i faced a problem.

My configuration:

websocket.xml - part of spring context

4条回答
  •  無奈伤痛
    2020-12-06 14:16

    I arrived on this page and - thanks to Boris Accepted Answer was motivated to reconsider the java approach as opposed to the xml approach which was causing the - /info=34424 with 404 error...whoops lost connection - I have Spring 4.2 in my project and many SockJS Stomp implementations usually work well with Spring Boot implementations. This implementation from Baeldung worked(for me without changing from Spring 4.2 to 5 or Boot). After Using the dependencies mentioned in his blog, it still gave me ClassNotFoundError. I added the below dependency to fix it.

    
            org.springframework
            spring-core
            4.2.3.RELEASE
        
    

    Baeldung's implementation curiously does not make any such calls

    flow/websocket/add/info?t=1540813753999
    

    What it does (on send and receive) is below. I am only pasting it in case people well-versed with these libraries can further add insights on this forum.

     >>> SEND
    destination:/app/chat
    content-length:38
    
    {"from":"nicholas","text":"try again"}
    
    <<< MESSAGE
    destination:/topic/messages
    content-type:application/json;charset=UTF-8
    subscription:sub-0
    message-id:m3p096zk-11
    content-length:53
    
    {"from":"nicholas","text":"try again","time":"13:46"}
    

提交回复
热议问题