Why does the stompClient.connect method not execute when using SockJS for WebSocket connections?

function connect() {        
    var socket = new SockJS("/socket");        
    stompClient = Stomp.over(socket);        
    stompClient.connect({}, function (frame) {            
        setConnected(true);            
    });
    console.log("test");    
}

when the front end uses sockjs.js and stomp.js for WebSocket connection, debug sees that when executing the stompClient.connect method, it does not enter the method body, but jumps directly to the console.log statement. Why?


do you mean your setConnected (true); ? this should be a callback, not an immediate


.

I don't know if the map of header is required. You can make a breakpoint or add a console, in the callback. If it is not required, you will enter the callback function.
or add an incorrect callback prompt.
stompClient.connect ({}, function (frame) {

)
    setConnected(true);            
},function(err){
console.log(error.headers.message)
});

problem solved
I originally wrote the connect () method in the problem in the callback function of a successful Ajax request. I think it may be because there is a conflict between the HTTP protocol and the WebSocket protocol in this case. I don't know exactly what the reason is.
the most coquettish thing is that both the foreground and the backstage have not reported wrong, which is puzzling.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5628d-4ca96.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5628d-4ca96.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?