Retreive socket id from ngx-socket-io


I’ve recently started using ngx-socket-io, and i’ve run into some difficultys as i wanted to retreive the socket id. Does anyone know how this can be done ? (I’m using the service intialization not the one in the app Module)
Thank you in advance.


import { Socket } from 'ngx-socket-io';
constructor(private socket: Socket) {}
ngOnInit() {
    this.socket.on('connect', () => console.log(;

Answered By – FBaez51

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published