socket.io-client icon indicating copy to clipboard operation
socket.io-client copied to clipboard

WebSocket Failing to Connect in Debug Mode - "Allowing connection to any root cert" Error

Open echonikul opened this issue 1 year ago • 0 comments

export var abhaSocket;

const initializeAbhaSocket = () => { return new Promise(async (resolve, reject) => { try { // Using different URLs for staging and production modes let url = isRelease ? "wss://dummy-production-url.com" : "wss://dummy-staging-url.com"; abhaSocket = null;

  // WebSocket configuration
  const webSocket = io(url, {
    transports: ["websocket"],
    extraHeaders: {
      Authorization: `Bearer dummyAccessToken`,
      "x-auth-token": `Bearer dummyXToken`,
      "r-token": `Bearer dummyRefreshToken`,
    },
    autoConnect: true,
    reconnection: true,
  });

  // Assign the socket instance
  abhaSocket = webSocket;

  // Resolve the promise with the WebSocket
  resolve(webSocket);
} catch (err) {
  console.log("error on abhaSocket connection");
  reject(err);
}

}); };

// Exporting the abhaSocket for use in other parts of the application export { initializeAbhaSocket };

// Note: This WebSocket connection works fine in release mode, but in debug mode, // it fails to connect and logs errors related to certificates.

echonikul avatar Oct 04 '24 10:10 echonikul