title: Subscribe to topic with Stomp Client but i don't get any notification don't work React Native and work on Angular
body: <p>I want to subscribe to the topic with <code>SockJS</code> and <code>Stomp Client</code> I put the subscribe on the client inside <code>onConnect</code> function to make sure that the Client is connected, This my configuration for:</p>
  <pre><code>import getEnvVars from &quot;./environment&quot;;
  import { socketUrl } from &quot;../services/GlobalUrls&quot;;
  import SockJS from &quot;sockjs-client&quot;;
  import { Client } from &quot;@stomp/stompjs&quot;;
  /**
   * Please notice that this import not used on this file
   * but used on the library of this file
   * so please don't delete it or the app will throw an error
   *  */
  import * as encoding from &quot;text-encoding&quot;;
  
  const url = getEnvVars().apiUrl + socketUrl;
  let _stompClient = null;
  
  const webSocket = () =&gt; {
    //const [message, newMessage] = useState();
  
    _stompClient = new Client({
      brokerURL: url,
      connectHeaders: {},
      debug: (str) =&gt; {
        console.log(str);
      },
      reconnectDelay: 500,
      heartbeatIncoming: 4000,
      heartbeatOutgoing: 4000,
      logRawCommunication: false,
      webSocketFactory: () =&gt; {
        return SockJS(url);
      },
      onStompError: (frame) =&gt; {
        console.log(&quot;Stomp Error&quot;, frame);
      },
      onConnect: (frame) =&gt; {
        console.log(&quot;Stomp Connect&quot;, frame);
        if (_stompClient.connected) {
          _stompClient.subscribe(&quot;topic/notification&quot;, (message) =&gt; {
            console.log(&quot;message&quot;);
            if (message.body) {
              let notification = JSON.parse(message.body);
              if (notification.type == &quot;MESSAGE&quot;) {
                console.log(&quot;MESSAGE&quot;, notification);
              } else if (notification.type == &quot;INVITATION&quot;) {
                console.log(&quot;INVITATION&quot;, notification);
              } else if (notification.type == &quot;REMOVED&quot;) {
                console.log(&quot;REMOVED&quot;, notification);
              }
            }
          });
        }
      },
      onDisconnect: (frame) =&gt; {
        console.log(&quot;Stomp Disconnect&quot;, frame);
      },
      onWebSocketClose: (frame) =&gt; {
        console.log(&quot;Stomp WebSocket Closed&quot;, frame);
      },
      onWebSocketError: (frame) =&gt; {
        console.log(&quot;Stomp WebSocket Error&quot;, frame);
      },
    });
  
    _stompClient.activate();
    return _stompClient;
  };
  
  export default webSocket;
  </code></pre>
  <p>On my react native component:</p>
  <pre><code>  useEffect(() =&gt; {
      webSocket();
    }, []);
  </code></pre>
  <p>My debug show this:</p>
  <pre><code>Opening Web Socket...
  accept-version:1.0,1.1,1.2
  heart-beat:4000,4000
  Web Socket Opened...
  heart-beat:0,0
  version:1.2
  content-length:0
  id:sub-0
  destination:topic/notification/8
  &gt;&gt;&gt; CONNECT
  accept-version:1.0,1.1,1.2
  heart-beat:4000,4000
  
  
  Received data
  &lt;&lt;&lt; CONNECTED
  heart-beat:0,0
  version:1.2
  content-length:0
  
  
  connected to server undefined
  Stomp Connect FrameImpl {
    &quot;_binaryBody&quot;: Uint8Array [],
    &quot;command&quot;: &quot;CONNECTED&quot;,
    &quot;escapeHeaderValues&quot;: false,
    &quot;headers&quot;: Object {
      &quot;heart-beat&quot;: &quot;0,0&quot;,
      &quot;version&quot;: &quot;1.2&quot;,
    },
    &quot;isBinaryBody&quot;: true,
    &quot;skipContentLengthHeader&quot;: false,
  }
  &gt;&gt;&gt; SUBSCRIBE
  id:sub-0
  destination:topic/notification
  </code></pre>
  <p>The same debug showed on the angular app and I got the message but on my react native app I got nothing.
  Angular setup:</p>
  <pre><code> const ws = new SockJS(this.globalService.BASE_URL + &quot;/socket&quot;);
      this.stompClient = Stomp.over(ws);
      this.stompClient.debug = () =&gt; {};
      const that = this;
      this.stompClient.connect({}, function(frame) {
        that.stompClient.subscribe(
          &quot;/topic/notification&quot;,
          message =&gt; {
            if (message.body) {
              let notification = JSON.parse(message.body);
              if (notification.type == &quot;MESSAGE&quot;) {
                that.messageListService.setNotificationObs(notification);
              } else if (notification.type == &quot;INVITATION&quot;) {
                that.messageListService.setInvitationNotificationObs(notification);
              } else if (notification.type == &quot;REMOVED&quot;) {
                that.messageListService.removeInvitationNotificationObs(notification);
              }
            }
          }
        );
      });
  </code></pre>