1、问题:
出现以下错误:
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())
...
}
请参看这篇文章:https://segmentfault.com/a/11...。
new SockJS(YOUR_END_POINT)的endPoint必须与你在websocket config 里注册的endPoint一致。
registry.addEndpoint(YOUR_END_POINT).withSockJS();