Closed duongxinh2003 closed 10 months ago
I'd resolve this issue. Maybe the conflict caused by @EnableWebSocketSecurity
and class AbstractSecurityWebSocketMessageBrokerConfigurer
.
In the backend, I remove @EnableWebSocketSecurity
and only use class AbstractSecurityWebSocketMessageBrokerConfigurer
@Configuration
//@EnableWebSocketSecurity
public class WebsocketSecurityConfiguration extends AbstractSecurityWebSocketMessageBrokerConfigurer {
}
- Frontend side, I add some configuration like this
rxStomp.configure({
// brokerURL: ws://localhost:8080/websocket/tracker/4/efa0b978/websocket
,
webSocketFactory: function () {
// Note that the URL is different from the WebSocket URL
return new SockJS(http://localhost:8080/websocket/tracker?token=${hash}
);
},
connectHeaders: {
Authorization: token,
},
heartbeatIncoming: 0,
heartbeatOutgoing: 0,
});
![image](https://github.com/spring-projects/spring-framework/assets/25058528/c550467a-1479-42bb-bb5a-d6b397e4d5c1)
Affects: 6.1.1
Client: Use rx-Stomp js lib to connect websocket
WebSocketMessageBrokerConfigurer
:com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'CONNECT': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false') at [Source: (String)"CONNECT accept-version:1.2,1.1,1.0 heart-beat:0,0
\u0000"; line: 1, column: 8] at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:2477) at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:760) at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._reportInvalidToken(ReaderBasedJsonParser.java:3041) at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddValue(ReaderBasedJsonParser.java:2082) at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:808) at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4912) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4818) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3772) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3740) at org.springframework.web.socket.sockjs.frame.Jackson2SockJsMessageCodec.decode(Jackson2SockJsMessageCodec.java:64) at org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession.handleMessage(WebSocketServerSockJsSession.java:187) at org.springframework.web.socket.sockjs.transport.handler.SockJsWebSocketHandler.handleTextMessage(SockJsWebSocketHandler.java:93) at org.springframework.web.socket.handler.AbstractWebSocketHandler.handleMessage(AbstractWebSocketHandler.java:43) at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.handleTextMessage(StandardWebSocketHandlerAdapter.java:113) at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$3.onMessage(StandardWebSocketHandlerAdapter.java:84) at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$3.onMessage(StandardWebSocketHandlerAdapter.java:81) at io.undertow.websockets.jsr.FrameHandler$7.run(FrameHandler.java:288) at io.undertow.websockets.jsr.ServerWebSocketContainer$1.call(ServerWebSocketContainer.java:170) at io.undertow.websockets.jsr.ServerWebSocketContainer$1.call(ServerWebSocketContainer.java:167) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.websockets.jsr.ServerWebSocketContainer.invokeEndpointMethod(ServerWebSocketContainer.java:618) at io.undertow.websockets.jsr.ServerWebSocketContainer.invokeEndpointMethod(ServerWebSocketContainer.java:608) at io.undertow.websockets.jsr.FrameHandler.invokeTextHandler(FrameHandler.java:268) at io.undertow.websockets.jsr.FrameHandler.onFullTextMessage(FrameHandler.java:319) at io.undertow.websockets.core.AbstractReceiveListener$2.complete(AbstractReceiveListener.java:156) at io.undertow.websockets.core.AbstractReceiveListener$2.complete(AbstractReceiveListener.java:152) at io.undertow.websockets.core.BufferedTextMessage.read(BufferedTextMessage.java:105) at io.undertow.websockets.core.AbstractReceiveListener.readBufferedText(AbstractReceiveListener.java:152) at io.undertow.websockets.core.AbstractReceiveListener.bufferFullMessage(AbstractReceiveListener.java:90) at io.undertow.websockets.jsr.FrameHandler.onText(FrameHandler.java:184) at io.undertow.websockets.core.AbstractReceiveListener.handleEvent(AbstractReceiveListener.java:44) at io.undertow.websockets.core.AbstractReceiveListener.handleEvent(AbstractReceiveListener.java:33) at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) at io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(AbstractFramedChannel.java:974) at io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(AbstractFramedChannel.java:954) at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66) at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89) at org.xnio.nio.WorkerThread.run(WorkerThread.java:591)
@Configuration @EnableWebSocketSecurity public class WebsocketSecurityConfiguration extends AbstractSecurityWebSocketMessageBrokerConfigurer { }