-
Couldn't load subscription status.
- Fork 38.8k
Description
Clark Duplichien opened SPR-13190 and commented
Currently running spring 4.2.0.BUILD-SNAPSHOT
Adding the websocket:decorator-factories element to a websocket:message-broker configuration in XML will prevent the associated SubProtocolWebSocketHandler from starting. Any attempts to make websocket connections will hang on the CONNECT frame.
Connect log with websocket:decorator-factories in place:
2015-07-01 12:57:08,817 DEBUG: org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator - New WebSocketServerSockJsSession[id=2r1eakba]
2015-07-01 12:57:08,819 TRACE: org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator - Handling TextMessage payload=[CONNECT
ac..], byteCount=56, last=true] in WebSocketServerSockJsSession[id=2r1eakba]
2015-07-01 12:57:08,820 DEBUG: org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler - Processing CONNECT user=cduplichien session=2r1eakba
2015-07-01 12:57:08,829 DEBUG: org.springframework.web.socket.messaging.SubProtocolWebSocketHandler - No session for GenericMessage [payload=byte[0], headers={simpMessageType=CONNECT_ACK, simpUser=org.springframework.security.authentication.UsernamePasswordAuthenticationToken@fb48ec72: Principal: org.springframework.security.core.userdetails.User@40dd7ab4: Username: cduplichien; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ...omitted..., simpHeartbeat=[J@6b8741, simpSessionId=2r1eakba}], simpSessionId=2r1eakba}]
Connect log without websocket:decorator-factories in place:
2015-07-01 12:54:35,054 DEBUG: org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator - New WebSocketServerSockJsSession[id=4hbhkzih]
2015-07-01 12:54:35,054 TRACE: org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator - Handling TextMessage payload=[CONNECT
ac..], byteCount=56, last=true] in WebSocketServerSockJsSession[id=4hbhkzih]
2015-07-01 12:54:35,054 DEBUG: org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler - Processing CONNECT user=cduplichien session=4hbhkzih
2015-07-01 12:54:38,642 INFO : org.springframework.web.socket.config.WebSocketMessageBrokerStats - WebSocketSession[1 current WS(1)-HttpStream(0)-HttpPoll(0), 2 total, 0 closed abnormally (0 connect failure, 0 send limit, 0 transport error)], stompSubProtocol[processed CONNECT(2)-CONNECTED(2)-DISCONNECT(0)], stompBrokerRelay[null], inboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], outboundChannelpool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], sockJsScheduler[pool size = 1, active threads = 1, queued tasks = 0, completed tasks = 0]
The "No Session for Generic Message" log is produced when using websocket:decorator-factories because the SubProtocolWebSocketHandler was not started when the CONNECT frame was received, and did not create a new session.
In Debugging, there actually was a SubProtocolWebSocketHandler which was started by the SmartLifecycle, but it was a different instance than the one wrapped by the decorator factory configured through websocket:decorator-factories.
Manually starting the SubProtocolWebSocketHandler from my DecoratorFactory as a workaround makes the connections usable, and the websockets function as expected.
It would seem that a separate instance is provided to the DecoratingFactoryBean by MessageBrokerBeanDefinitionParser, and this instance is never started.
Affects: 4.2 RC2