Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-13190

STOMP CONNECT ignored ("No session for...") when using <websocket:decorator-factories>

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 4.2 RC2
    • Fix Version/s: 4.1.8, 4.2 RC3
    • Component/s: Messaging:WebSocket
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      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.

        Attachments

          Activity

            People

            Assignee:
            rstoya05-aop Rossen Stoyanchev
            Reporter:
            cduplichien Clark Duplichien
            Last updater:
            Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              2 years, 1 week, 1 day ago