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

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

Open
echonikul opened this issue Oct 4, 2024 · 0 comments

Comments

@echonikul
Copy link

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.

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

1 participant