title: Access HTTP Session in WebSocketHandler (Spring-websocket)
body: <p>Dears,
  I'm trying to get an HTTPSession in my WebSocketHandler. I could do it successfully when I was using 'javax.websocket-api' but I'm now using 'Spring-Websocket'.</p>
  
  <p>The config :</p>
  
  <pre><code>@ConditionalOnWebApplication
  @Configuration
  @EnableWebSocket
  public class WebSocketConfigurator implements WebSocketConfigurer {
  
      @Autowired
      private ApplicationContext context;
  
      @Override
      public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
          MyEndpoint endpoint = context.getBean(MyEndpoint.class);
          registry.addHandler(endpoint, "/signaling");
      }
  }
  </code></pre>
  
  <p>When the connection is established :</p>
  
  <pre><code>    @Component
      public class MyEndpoint implements WebSocketHandler {
  
          private WebSocketSession wsSession;
  
          @Override
          public void afterConnectionEstablished(WebSocketSession webSocketSession) throws Exception {
              this.wsSession = webSocketSession;
              // need to get the HTTP SESSION HERE        
              log.info("Opening: " + webSocketSession.getId());
          }
      }
  </code></pre>
  
  <p>And now this is an example of how I could do it using 'javax.websocket-api' :</p>
  
  <p>The configuration :</p>
  
  <pre><code>@ServerEndpoint(value = "/signaling", //
          decoders = MessageDecoder.class, //
          encoders = MessageEncoder.class,
          configurator = MyEndpointConfigurator.class)
  /***
   * define signaling endpoint         
   */
  public class MyEndpoint extends NextRTCEndpoint {
  
  }
  </code></pre>
  
  <p>Then I was Injecting the HTTPSession modifying the handshake :</p>
  
  <pre><code>public class MyEndpointConfigurator extends ServerEndpointConfig.Configurator {
      @Override
      public void modifyHandshake(ServerEndpointConfig config,
              HandshakeRequest request,
              HandshakeResponse response) {
          HttpSession httpSession = (HttpSession) request.getHttpSession();
          config.getUserProperties().put(HttpSession.class.getName(), httpSession);
      }
  }
  </code></pre>
  
  <p>And finally, it was accessible when the WS connection was established :</p>
  
  <pre><code>    @OnOpen
      public void onOpen(Session session, EndpointConfig config) {
          this.wsSession = session;
          this.httpSession = (HttpSession) config.getUserProperties().get(HttpSession.class.getName());
          log.info("Opening: " + session.getId());
  
          server.register(session, httpSession);
      }
  </code></pre>
  
  <p>I could not succeed to do something similar with 'Spring Websocket'. Any solution ? Please do not propose classes from StompJS as I'm not using it.</p>