title: Websockets server with SockJS (NodeJS) + STOMP Clients
body: <p>I have a node app with sockjs sockets.</p>
  
  <p>Some HTML / JS clients use stomp over sock JS but I don't understand how subscription works :</p>
  
  <pre><code>$scope.initSockets = function() {
      $scope.socket.client = new SockJS('http://localhost:8080/websockets'); =&gt; WORKS
  
      $scope.socket.stomp = Stomp.over($scope.socket.client);
      $scope.socket.stomp.connect({}, function() {
          $scope.socket.stomp.subscribe("/topic", $scope.notify); =&gt; NOTIFY Is never called
      });
      $scope.socket.client.onclose = $scope.reconnect;
  };
  </code></pre>
  
  <p>Clients are connected, events are logged but $scope.notify is never called. How can we configure topic subscription ?</p>
  
  <p>Edit : </p>
  
  <p>Note sure I'm clear.</p>
  
  <p>I'm using sockjs module as a websocket server.</p>
  
  <p>There's not a lot of configuration :</p>
  
  <p><code>echo.installHandlers(server, {prefix:'/websockets'});</code></p>
  
  <pre><code> // on new connection event
  echo.on('connection', function(conn) {
  
      console.log('New client connected : ' + conn.id);
  
      // add this client to clients object
      clients[conn.id] = conn;
  
      // on connection close event
      conn.on('close', function() {
          console.log('Client disconnected ' + conn.id);
          delete clients[conn.id];
      });
  });
  </code></pre>
  
  <p>Clients use stomp protocol over sockJS client.</p>
  
  <p>They receive messages (regards to client logs), but their are not related to "topic" and are not parsed.</p>
  
  <p>I don't understand how subscription works and how to configure it with sockjs on server side. </p>