title: Spring Websockets/Stomp upgrade to secure websockets
body: <p>I have 2 Java applications that communicate using Spring websockets. I use ActiveMQ Version 5.12.3. I run the apps on a TomEE Server. This is the configuration i use in tomee.xml for ActiveMQ:</p>
  
  <pre><code>&lt;Resource id="MyAppMessageBus" type="ActiveMQResourceAdapter"&gt;
      BrokerXmlConfig =  broker:(tcp://localhost:61616,ws://0.0.0.0:61614,stomp://0.0.0.0:61613)
      ServerUrl       =  tcp://localhost:61616
  &lt;/Resource&gt;
  </code></pre>
  
  <p>This is my Java code for connecting:</p>
  
  <pre><code>    if (brokerUrl.startsWith("ws")) {
          WebSocketClient transport = new StandardWebSocketClient();
          stompClient = new WebSocketStompClient(transport);
      }
  
      stompClient.setMessageConverter(new MappingJackson2MessageConverter());
      stompClient.setTaskScheduler(taskScheduler);
      stompClient.setDefaultHeartbeat(heartbeat);
      stompClient.connect(brokerUrl, handler);
  </code></pre>
  
  <p>I can connect successfully using the following broker url: ws://localhost:61614</p>
  
  <p>What i would like to do, is connect using secure websockets. When i change the url in tomee.xml to use wss:// and update the brokerurl in my code, i get the following exception: </p>
  
  <pre><code>javax.websocket.DeploymentException: The HTTP request to initiate the WebSocket connection failed
      at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:434) ~[tomcat7-websocket.jar:7.0.68]
      at org.springframework.web.socket.client.standard.StandardWebSocketClient$1.call(StandardWebSocketClient.java:152) ~[spring-websocket-4.2.5.RELEASE.jar:4.2.5.RELEASE]
      at org.springframework.web.socket.client.standard.StandardWebSocketClient$1.call(StandardWebSocketClient.java:149) ~[spring-websocket-4.2.5.RELEASE.jar:4.2.5.RELEASE]
      at java.util.concurrent.FutureTask.run(FutureTask.java:262) ~[na:1.7.0_80]
      at java.lang.Thread.run(Thread.java:745) [na:1.7.0_80]
  Caused by: java.util.concurrent.ExecutionException: java.net.ConnectException: Connection refused
      at sun.nio.ch.PendingFuture.get(PendingFuture.java:202) ~[na:1.7.0_80]
      at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:376) ~[tomcat7-websocket.jar:7.0.68]
      ... 4 common frames omitted
  Caused by: java.net.ConnectException: Connection refused
      at sun.nio.ch.UnixAsynchronousSocketChannelImpl.checkConnect(Native Method) ~[na:1.7.0_80]
      at sun.nio.ch.UnixAsynchronousSocketChannelImpl.finishConnect(UnixAsynchronousSocketChannelImpl.java:252) ~[na:1.7.0_80]
      at sun.nio.ch.UnixAsynchronousSocketChannelImpl.finish(UnixAsynchronousSocketChannelImpl.java:198) ~[na:1.7.0_80]
      at sun.nio.ch.UnixAsynchronousSocketChannelImpl.onEvent(UnixAsynchronousSocketChannelImpl.java:213) ~[na:1.7.0_80]
      at sun.nio.ch.EPollPort$EventHandlerTask.run(EPollPort.java:293) ~[na:1.7.0_80]
      ... 1 common frames omitted
  </code></pre>
  
  <p>Does anyone know an easy way to enable secure websockets? Do i need to add an additional transport in my code or add something to my server configuration? </p>