Socket.js and stomp.js 建立stomp 端点时,出现 以下错误

新手上路,请多包涵
1、问题:

出现以下错误:

clipboard.png

function connect(url) {
    var httpUrl="http://"+window.location.host+url;
    var socket= new SockJS(httpUrl);
    var headers = {
        login: 'mylogin',
        passcode: 'mypasscode',
        // additional header
        'client-id': 'my-client-id'
    };
    stompClient = Stomp.over(socket);
    // 向服务器发起websocket连接并发送CONNECT帧
    stompClient.connect(
        {},
        function connectCallback (frame) {

后台:

public void registerStompEndpoints(StompEndpointRegistry stompEndpointRegistry) {
        log.info("stomp ... ... ... ");
        stompEndpointRegistry
                .addEndpoint("/chat")
                .addInterceptors(new CocoshakeInterceptor())
                ...
                }
阅读 3k
1 个回答

请参看这篇文章:https://segmentfault.com/a/11...
new SockJS(YOUR_END_POINT)的endPoint必须与你在websocket config 里注册的endPoint一致。
registry.addEndpoint(YOUR_END_POINT).withSockJS();

推荐问题
宣传栏