You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Long delay before "Go private" button is enabled #55
That was just an example, you can enable that by yourself as follows:
const p2p = new P2P(socket);
setInterval(function(){
if (p2p.usePeerConnection === true){
// now the connection is established and ready
}else{
// the connection is not ready yet
}
For future readers: Remove the "trickle" parameter from the constructor in the chat example. That is what is done in the example above -> By only passing the socket the SocketIOp2p constructor, the default params are 5 clients, and autoUpgrade: true. So as soon as clients can connect to eachother they are "upgraded" to webRTC. I am not sure what the trickle parameter is... could find the documentation yet
I was able to fix this by setting trickle: true in that peerOpts object.
That fixed the problem, but introduced a new one where the server would crash if either browser reloaded. The fix for that was to modify socket.io-p2p-server.js to not try to use client methods if the client doesn't exist. As in:
Line 44:
client?.emit('peer-signal', data)
That little question mark is all it took. I pulled the file out of node modules and am now referencing it directly. At some point somebody who cares about such things should make a PR for that project.
Activity
AdamSEY commentedon Feb 26, 2020
That was just an example, you can enable that by yourself as follows:
const p2p = new P2P(socket);
setInterval(function(){
if (p2p.usePeerConnection === true){
// now the connection is established and ready
}else{
// the connection is not ready yet
}
}, 1000);
twofingerrightclick commentedon Nov 5, 2020
For future readers: Remove the "trickle" parameter from the constructor in the chat example. That is what is done in the example above -> By only passing the socket the SocketIOp2p constructor, the default params are 5 clients, and
autoUpgrade: true. So as soon as clients can connect to eachother they are "upgraded" to webRTC. I am not sure what the trickle parameter is... could find the documentation yetjasonkester commentedon Apr 7, 2026
I was able to fix this by setting
trickle: truein thatpeerOptsobject.That fixed the problem, but introduced a new one where the server would crash if either browser reloaded. The fix for that was to modify
socket.io-p2p-server.jsto not try to use client methods if the client doesn't exist. As in:Line 44:
That little question mark is all it took. I pulled the file out of node modules and am now referencing it directly. At some point somebody who cares about such things should make a PR for that project.