Error connecting to OpenAI: Could not connect to "wss://api.openai.com/v1/realtime"

I am trying to connect to realtime API using this code -
const ws = new WebSocket(${this.url}${model ? ?model={model}` : ''}`, [ 'realtime', `openai-insecure-api-key.{this.apiKey}, 'openai-beta.realtime-v1', ]); ws.addEventListener('message', (event) => { const message = JSON.parse(event.data); this.receive(message.type, message); }); return new Promise((resolve, reject) => { const connectionErrorHandler = () => { this.disconnect(ws); reject(new Error(Could not connect to “{this.url}"`)); }; ws.addEventListener('error', connectionErrorHandler); ws.addEventListener('open', () => { this.log(`Connected to "{this.url}”); ws.removeEventListener('error', connectionErrorHandler); ws.addEventListener('error', () => { this.disconnect(ws); this.log(Error, disconnected from “{this.url}"`); this.dispatch('close', { error: true }); }); ws.addEventListener('close', () => { this.disconnect(ws); this.log(`Disconnected from "{this.url}”`);
this.dispatch(‘close’, { error: false });
});
this.ws = ws;
resolve(true);
});
});

I am getting the following error - Error connecting to OpenAI: Could not connect to “wss://api.openai.com/v1/realtime”

Has anyone faced this issue? Also how can I print the actual error?

++
When I try to connect to the same URL with python I get the following error -
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1006)