Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

peer.connect not open on some users #1189

Open
Elabbasy00 opened this issue Jan 11, 2024 · 0 comments
Open

peer.connect not open on some users #1189

Elabbasy00 opened this issue Jan 11, 2024 · 0 comments
Labels
bug client related to peerjs client

Comments

@Elabbasy00
Copy link

Elabbasy00 commented Jan 11, 2024

I am using peerjs custom server on nodejs
and the client is Electron app

    const handelPeer = async (peerId: string) => {
    const id = `${Math.random().toString(16).slice(2)}_${user?.username
      ?.replaceAll(' ', '_')
      .toString()!}`;


    const peer = new Peer(id, {
      host: 'xxx.xxxx.xxx',
      path: '/peerjs',
      secure: true,
    });


    peer.on('open', () => {
   
      const connection = peer.connect(peerId); // Never called on some users 

      connection.on('open', async () => {
        dataSream.current = await createStream();
        callRef.current = peer.call(peerId, dataSream.current);


        callRef.current?.on('error', (e) => {
          console.log('error', e);
        });
        callRef.current?.on('close', () => {
          cleanUp(connection);
        });
      });

      connection.on('close', () => {
        cleanUp(connection);
      });
      connection.on('error', (e: any) => {
        console.log('got connection error', e);
      });
    });

    peer.on('disconnected', () => {
      console.log('disconnect');
      cleanUp();
    });

    peer.on('error', (error) => {

      cleanUp();

    });
  };

everything working great but it's not working on some users' devices without errors
after debugging I have figured that peer.connect never open even on setTimeOut
console.log(connection)

Screenshot 2024-01-11 at 6 09 20 PM
@Elabbasy00 Elabbasy00 changed the title peer.connect not called on some users peer.connect not open on some users Jan 11, 2024
@irgalamarr irgalamarr added the client related to peerjs client label Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug client related to peerjs client
Projects
None yet
Development

No branches or pull requests

3 participants