title: How to use websocket in spring boot and react js?
body: <p>I referred to this <a href="https://spring.io/guides/gs/messaging-stomp-websocket/" rel="nofollow noreferrer">spring boot doc</a> to create web socket in spring boot.</p>
  
  <p>I used <a href="https://www.npmjs.com/package/@stomp/stompjs" rel="nofollow noreferrer">stompjs</a> and <a href="https://www.npmjs.com/package/sockjs-client" rel="nofollow noreferrer">sockjs-client</a> </p>
  
  <pre><code>var socket = new SockJS('/gs-guide-websocket');
  //gives an error in below line
  stompClient = Stomp.over(socket);
  stompClient.connect({}, function (frame) {
      setConnected(true);
      console.log('Connected: ' + frame);
      stompClient.subscribe('/topic/greetings', function (greeting) {
          showGreeting(JSON.parse(greeting.body).content);
      });
  });
  </code></pre>