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

PeerJs Creating Default Connection on load #999

Open
cohenstyle opened this issue Sep 20, 2022 · 7 comments
Open

PeerJs Creating Default Connection on load #999

cohenstyle opened this issue Sep 20, 2022 · 7 comments
Labels
client related to peerjs client

Comments

@cohenstyle
Copy link

I'm importing PeerJS from the NPM module and using it with custom stun servers. This appears to work fine.
But when the app loads it makes an initial connection using the default servers before my code ever starts using the library.
How can I disable this?

@cohenstyle
Copy link
Author

It looks like it's likely part of the process to determine what the browser supports. Is there a way to make a best guess without making a connection?

@AlonBru
Copy link

AlonBru commented Jan 28, 2023

Can you include the code you are using or a minimal reproduction example?
otherwise it may be a bit hard to tell exactly what happens and why :), and
whether this is a bug or otherwise

@cohenstyle
Copy link
Author

It's been a while since I've used peerjs due to the other bug (can't send data in order.)
But I believe the code is:
import { Peer } from "peerjs";

Importing the library triggers a connection to a test server.

@AlonBru
Copy link

AlonBru commented Jan 29, 2023

I have created a codesandbox to try and recreate this, but had not noticed it happening just by importing.
Feel free to edit it if you're still interested in chasing this issue.

@cohenstyle
Copy link
Author

cohenstyle commented Jan 29, 2023

Ah sorry, my mistake. You have to create the Peer object.
The issue is in this line: https://github.com/peers/peerjs/blob/master/lib/util.ts#L62
It's called here: https://github.com/peers/peerjs/blob/master/lib/peer.ts#L211
When checking to see what's supported, a connection is made using the default config regardless of the config of the Peer connection.
This connects to Google and/or PeerJS servers regardless of which stun and turn servers the developer wants to use for the remainder of the app.
Thank you very much for looking into this.

@cohenstyle
Copy link
Author

This one may be higher priority though (I'm haven't followed the calls to determine why reliable is not being passed): #746

@irgalamarr irgalamarr added the client related to peerjs client label Feb 24, 2024
@Niksac
Copy link

Niksac commented Dec 29, 2024

I also noticed this behaviour today.
Is there any way to prevent this?

Just loading the PeerJS files without any additional code will connect to google and Peerjs servers.
This is problematic when under GDPR or similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client related to peerjs client
Projects
None yet
Development

No branches or pull requests

4 participants