title: Spring Boot Web Socket RabbitMQ not available
body: <p>I have simple spring boot app with web socket configuration.</p>
  
  <p>When i run my app with SimpleBroker(provided by spring) everything works fine, but when i want to use rabbitmq instead of SimpleBroker, i have some problems, my broker is "not available"</p>
  
  <pre><code>@Configuration
  @EnableWebSocketMessageBroker
  open class WebSocketConfig : ILogging by LoggingImp&lt;WebSocketConfig&gt;(), 
  WebSocketMessageBrokerConfigurer {
  
  @Autowired
  private lateinit var env: Environment
  
  override fun registerStompEndpoints(registry: StompEndpointRegistry) {
      registry.addEndpoint("/hig").setAllowedOrigins("*").withSockJS()
  }
  
  override fun configureMessageBroker(registry: MessageBrokerRegistry) {
      registry.setApplicationDestinationPrefixes("/app")
      val host = env.getProperty("spring.rabbitmq.host")!!
      val port = env.getProperty("spring.rabbitmq.port")!!.toInt()
      val login = env.getProperty("spring.rabbitmq.username")!!
      val pass = env.getProperty("spring.rabbitmq.password")!!
      log.debug("webSocket=$host, $port, $login, $pass")
  //        registry.enableSimpleBroker("/chat")
      registry.enableStompBrokerRelay("/chat")
              .setRelayHost(host)
              .setRelayPort(port)
              .setClientLogin(login)
              .setClientPasscode(pass)
              .setAutoStartup(true)
              .setSystemHeartbeatReceiveInterval(10000)
              .setSystemHeartbeatSendInterval(10000)
      }
  
  }
  </code></pre>
  
  <p>response from WebSocketMessageBrokerStats:</p>
  
  <pre><code>{
  "loggingPeriod": 1800000,
  "webSocketSessionStatsInfo": "0 current WS(0)-HttpStream(0)-HttpPoll(0), 0 total, 0 closed abnormally (0 connect failure, 0 send limit, 0 transport error)",
  "stompSubProtocolStatsInfo": "processed CONNECT(0)-CONNECTED(0)-DISCONNECT(0)",
  "stompBrokerRelayStatsInfo": "1 sessions, localhost:5672 (not available), processed CONNECT(1)-CONNECTED(0)-DISCONNECT(0)",
  "clientInboundExecutorStatsInfo": "pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0",
  "clientOutboundExecutorStatsInfo": "pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0",
  "sockJsTaskSchedulerStatsInfo": "pool size = 1, active threads = 0, queued tasks = 1, completed tasks = 0"
  }
  </code></pre>
  
  <p>Broker details:</p>
  
  <p><a href="https://i.stack.imgur.com/quqfU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/quqfU.png" alt="Overview"></a></p>
  
  <p><a href="https://i.stack.imgur.com/3d0bk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3d0bk.png" alt="Connections"></a></p>
  
  <pre><code>2018-02-15 23:03:56.367 [XNIO-2 task-16] DEBUG o.s.web.servlet.DispatcherServlet - DispatcherServlet with name 'dispatcherServlet' processing GET request for [/hig/websocket]
  2018-02-15 23:03:56.367 [XNIO-2 task-16] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Looking up handler method for path /hig/websocket
  2018-02-15 23:03:56.368 [XNIO-2 task-16] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Did not find handler method for [/hig/websocket]
  2018-02-15 23:03:56.368 [XNIO-2 task-16] DEBUG o.s.w.s.s.s.WebSocketHandlerMapping - Matching patterns for request [/hig/websocket] are [/hig/**]
  2018-02-15 23:03:56.368 [XNIO-2 task-16] DEBUG o.s.w.s.s.s.WebSocketHandlerMapping - URI Template variables for request [/hig/websocket] are {}
  2018-02-15 23:03:56.368 [XNIO-2 task-16] DEBUG o.s.w.s.s.s.WebSocketHandlerMapping - Mapping [/hig/websocket] to HandlerExecutionChain with handler [org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler@352c1b98] and 1 interceptor
  2018-02-15 23:03:56.368 [XNIO-2 task-16] DEBUG o.s.web.servlet.DispatcherServlet - Last-Modified value for [/hig/websocket] is: -1
  2018-02-15 23:03:56.369 [XNIO-2 task-16] DEBUG o.s.w.s.s.t.h.DefaultSockJsService - Processing transport request: GET http://localhost:8080/hig/websocket
  2018-02-15 23:03:56.370 [XNIO-2 task-16] DEBUG o.s.web.servlet.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
  2018-02-15 23:03:56.370 [XNIO-2 task-16] DEBUG o.s.web.servlet.DispatcherServlet - Successfully completed request
  2018-02-15 23:03:56.371 [XNIO-2 task-16] DEBUG o.s.w.s.h.LoggingWebSocketHandlerDecorator - New StandardWebSocketSession[id=Enl3glxP29UhO95gUafWViRXrXaZn3Kv556EVxW4, uri=/hig/websocket]
  2018-02-15 23:03:56.374 [clientOutboundChannel-7] DEBUG o.s.w.s.a.NativeWebSocketSession - Closing StandardWebSocketSession[id=Enl3glxP29UhO95gUafWViRXrXaZn3Kv556EVxW4, uri=/hig/websocket]
  2018-02-15 23:03:56.374 [clientOutboundChannel-7] DEBUG o.s.w.s.h.LoggingWebSocketHandlerDecorator - StandardWebSocketSession[id=Enl3glxP29UhO95gUafWViRXrXaZn3Kv556EVxW4, uri=/hig/websocket] closed with CloseStatus[code=1002, reason=]
  2018-02-15 23:03:56.374 [clientOutboundChannel-7] DEBUG o.s.w.s.m.SubProtocolWebSocketHandler - Clearing session Enl3glxP29UhO95gUafWViRXrXaZn3Kv556EVxW4
  2018-02-15 23:03:56.375 [clientOutboundChannel-8] DEBUG o.s.w.s.m.SubProtocolWebSocketHandler - No session for GenericMessage [payload=byte[0], headers={simpMessageType=OTHER, stompCommand=ERROR, nativeHeaders={message=[Broker not available.]}, simpSessionId=Enl3glxP29UhO95gUafWViRXrXaZn3Kv556EVxW4}]
  </code></pre>
  
  <p>For client i'm using angular 5</p>
  
  <p>When i'm using <code>registry.enableSimpleBroker("/chat")</code> everything works fine</p>
  
  <p>When i enable <code>registry.enableStompBrokerRelay("/chat")...</code> i'm getting:</p>
  
  <p>message:Broker not available.
  content-length:0</p>
  
  <p>pom.xml:</p>
  
  <pre><code> &lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;2.0.0.BUILD-SNAPSHOT&lt;/version&gt;
  &lt;/parent&gt;
  
  &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-websocket&lt;/artifactId&gt;
          &lt;version&gt;2.0.0.M7&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-amqp&lt;/artifactId&gt;
          &lt;version&gt;2.0.0.M7&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;io.projectreactor&lt;/groupId&gt;
          &lt;artifactId&gt;reactor-core&lt;/artifactId&gt;
          &lt;version&gt;3.1.3.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;io.projectreactor&lt;/groupId&gt;
          &lt;artifactId&gt;reactor-net&lt;/artifactId&gt;
          &lt;version&gt;2.0.8.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;io.projectreactor.ipc&lt;/groupId&gt;
          &lt;artifactId&gt;reactor-netty&lt;/artifactId&gt;
          &lt;version&gt;0.7.3.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;io.netty&lt;/groupId&gt;
          &lt;artifactId&gt;netty-all&lt;/artifactId&gt;
          &lt;version&gt;4.1.21.Final&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>