Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Still seeing retry after a successful connection. #615

Open
louisparks opened this issue Nov 10, 2023 · 1 comment
Open

Still seeing retry after a successful connection. #615

louisparks opened this issue Nov 10, 2023 · 1 comment

Comments

@louisparks
Copy link

louisparks commented Nov 10, 2023

Hello, I am running into a situation where sometimes I am getting the the beforeConnect callback coming in just after (1s) the onConnect callback (at least as seen in the logs). It then continues to call beforeConnect over and over again every 5secs (reconnectDelay=5000). Funny thing is, the websocket is actually connected to the broker and can receive messages from the broker. I am terribly confused. Any ideas? I am on 6.1.2

2023-11-09 04:22:25.628-06:00 (worker1 ) [debug] WebsocketService : Websocket Connected {
command: 'CONNECTED',
headers: { 'heart-beat': '45000,45000', version: '1.2' },
_binaryBody: {},
isBinaryBody: true,
escapeHeaderValues: false,
skipContentLengthHeader: false
}
2023-11-09 04:22:25.629-06:00 (worker1 ) [debug] WebsocketService : successfull websocket re-connect after 5540 retries.
2023-11-09 04:22:25.630-06:00 (worker1 ) [debug] WebsocketService : susbcribing to device topic
2023-11-09 04:22:25.631-06:00 (worker1 ) [debug] WebsocketService : subscribed to device topic
2023-11-09 04:22:25.632-06:00 (worker1 ) [debug] WebsocketService : starting heartbeat with server
2023-11-09 04:22:28.025-06:00 (worker1 ) [debug] WebsocketService : detected retry loop, will retry connection
2023-11-09 04:22:28.093-06:00 (main ) [debug] MainIpcHandlers : IPC_EVENT_CONNECT_STATUS_CHANGE status change { online: false }
2023-11-09 04:22:28.094-06:00 (render1 ) [debug] renderPreload : connection status change { online: false }
2023-11-09 04:22:28.096-06:00 (render1 ) [info] app.tsx : connection status change in app { online: false }

 this.wsclient.beforeConnect = async () => {
      await this.loadConnectionDetails();
      this.wsclient.brokerURL = this.brokerUrl();

      //Are we in a retry loop?
      if (this.connectionRetryCount == 0) {
        log.debug(`detected retry loop, will retry connection`);
      }
      this.connectionRetryCount++;
    };

    this.wsclient.onConnect = (frame) => {
      log.debug("Websocket Connected", frame);
      if (this.connectionRetryCount > 0) {
        log.debug(
          `successfull websocket re-connect after ${this.connectionRetryCount} retries.`
        );
      }
      // Subscribing to topics and starting heartbeat after connection
      this.subscribeToTopics();
      this.beginHeartbeat();
      this.connectionRetryCount = 0;
      this.lastServerConnectTime = new Date();
      this.initialized = true;
    };
@kum-deepak
Copy link
Member

Maybe you have already resolved this issue. If not please provide the following:

  • What is your environment - web browser, React Native, or NodeJS?
  • Are you using it with React or Angular?
  • Please share the entire console output - quite often the error might have occured a while back

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants