Store object in local storage

On every on connection socket- io auto generates values for id etc for the new user so even when creating new tabs it creates a new instance of that user which s bad for user experience. so i figured out that if i can store the socket session on user login and get it from localstorage when its needed, there will be consistency across tabs so here is my method in angular

onLoginCreateSocket() {
    const socket = io.connect(`${environment.domain}` , {
      query: {token: this.authservice.authToken}
    const JSONSOCKET = JSON.stringify(socket);
    localStorage.setItem('socket', JSONSOCKET);

but i get this error

ERROR TypeError: Converting circular structure to JSON

so i know what the error means but how do i resolve it so i can achieve my purpose. Thank you