zyro23 / grails-spring-websocket

93 stars 28 forks source link

Error during WebSocket handshake: Unexpected response code: 404 #47

Closed asuraphel closed 7 years ago

asuraphel commented 7 years ago

I have setup the 1.3.1 version of the plugin as per the docs but I get the following error in Chrome:

sockjs.js?compile=false:1213 WebSocket connection to 'ws://localhost:8098/hms/stomp/428/nb0d01u8/websocket' failed: Error during WebSocket handshake: Unexpected response code: 404

zyro23 commented 7 years ago

please attach a sample app reproducing the issue. clearly, it works by following the docs for other people. maybe the 404 just means that there is no websocket support and after that sock.js uses a fallback transport?

asuraphel commented 7 years ago

@zyro23 Is tomcat 7.0.52+ required? I tried upgrading but I am having issues with it.

asuraphel commented 7 years ago

@zyro23 just solved my issue. I see no errors now.. If I can.. I have one more question though. client.send doesn't seem to do anything. I used chrome dev tools to inspect network traffic. Nothing seems to show up. What could I be missing?

Here is my code:

    $(function() {
        var socket = new SockJS("/appName/stomp");
        var client = Stomp.over(socket);

        $(".call-nurse-button").click(function() {
            client.send("/app/messageDestination", {}, 'Message');
        });
    });

Log on console:

>>> SEND destination:/app/messageDestination content-length:26

Message

UPDATE:

I properly inspected the websocket frames and I was wrong. client does actually send the frames! What I couldn't do now is actually get request hit the action with @MessageMapping annotation. Yes, I prefixed the destination with /app.

Thanks!

asuraphel commented 7 years ago

Solved. Thanks for your responsiveness.