Unable to get the socket id from the socket json array in ionic socket programming

I am developing a module where two users can video chat with each other in Ionic 5/6 and Angular and socket programming. I am new in socket programming. The problem is I’m not getting the socket id from the socket JSON array in live server but working perfectly in my localhost. Please have a look at the below code.

Here is my ts file code – importing the socket file in the ts file –

import {Socket} from 'ngx-socket-io';

Here is my constructor where I have created the socket instance –

constructor(private socket: Socket){}

Here is the function where I want the socket id –

   userId = "123";
   const that = this;
   return new Observable((observer) => {
      console.log(that.socket.ioSocket.id);  //for example -- "f2fWBqwOFPQBRPpsAAAF"
      that.socket.emit('PRESENT_CLIENT', {socketId: that.socket.ioSocket.id , userId: userId});
   }).catch(err => {

Please see the attached image, where you can see the whole json array that is printed in the browser’s console

When I run this code in localhost it is working perfectly. I am getting the id from the “that.socket.ioSocket.id” but in live server its showing “undefined”. When console the “that.socket” it is showing the JSON array where “id” is present with its value but couldn’t able to fetch it. But from the same place I can fetch and console the other array variables and there values. I’m completely puzzled with this. Please help.