Ionic 3 Fetch Data Chat / Detect change in db

Hi,
I have a chat app made in ionic but I do not know how to always fetch data from server without refreshing so it that could be a problem when more devices are using it ?
I’m using a Timeout to call the function and get data every sec.
It would be better if i could just detect a change in db.

 getMensajes() : void
   { 
       this.http2.get('http://192.168.100.25/ct/msgs.php').subscribe((data2 : any) =>
      {
         //console.dir(data2);
         this.mensajes = data2;
      },
      (error : any) =>
      {
         console.dir(error);
      });
      
      setTimeout(() => {
        this.getMensajes();
    }, 1000);
   }

Solved by using Socket.io.