stomp-js / stompjs

Javascript and Typescript Stomp client for Web browsers and node.js apps
Apache License 2.0
738 stars 80 forks source link

Client has been marked inactive, will not attempt to connect. #609

Closed taj567 closed 2 months ago

taj567 commented 8 months ago

m not able to connect with the socket using react native getting error like Client has been marked inactive, will not attempt to connect.

do anyone have solution... this is the codee & current versions am using:

"@stomp/stompjs": "^7.0.0", "react-native": "0.71.0",


   const client = new Client({
        brokerURL: `${SOCKET_BASE_URL}${token}`, // Replace with your STOMP broker URL
        reconnectDelay: 10000,
        heartbeatIncoming : 5000,
        heartbeatOutgoing : 5000,
        forceBinaryWSFrames : true,
        appendMissingNULLonIncoming : true,
        onConnect: function (frame) {
          console.log('Connected: ' + frame);
          // Subscribe to a destination
          client.subscribe('/topic/continue_watching', function (message) {
            console.log('Received message:', message.body);
          });
          // Send a message
          client.publish({
            destination: '/app/continue_watching',
            // headers: "content-type:application/json",
            headers: {'content-type': 'application/json'},
            body: {
              userId: data?.data?.account?.id,
              tenantId: 123456,
              accountId: data?.data?.account?.id,
              subscriptionId: 345678,
              videoId: id,
              type: 'sample_type',
              duration: 3600,
              retentionTime: 7200,
              modelId: 987654,
            },
          });
        },
        debug: function (str) {
          console.log(str, 'Debug__');
        },
        // onWebSocketError: (e) => {
        //   console.log(e,"onWebSocketError")
        // },
        // onDisconnect : e => {
        //   console.log(e, "onDisconnect")
        // },
        // onWebSocketError : (e) => {
        //   console.log(e,"onWebSocketError")
        // },
        // onDisconnect : e => {
        //   console.log(e, "onDisconnect")
        // },
        // logRawCommunication: e => {
        //   console.log(e,  "logRawCommunication")
        // },
        // onStompError : e => {
        //   console.log(e, "StompError")
        // },
        // debug : e => {
        //   console.log(e, "debug")
        // }
      });
kum-deepak commented 8 months ago

Please attach your full log.

taj567 commented 8 months ago

@kum-deepak Thank you for responding...

Screenshot 2023-11-06 at 10 50 12 AM

am not able to connect with the stomp.

kum-deepak commented 8 months ago

Please attache your entire log - from the very beginning. In this case, the error might have occurred a while back.

taj567 commented 8 months ago

@kum-deepak , Thanks after some research added added text-encoder.

followed this document https://stomp-js.github.io/guide/stompjs/rx-stomp/polyfills-for-stompjs.html.