-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Please, check for existing issues to avoid duplicates.
- No similar issues found.
What happened?
hello, I'm using Vue 3 with PeerJS.
"peerjs": "^1.5.4",
"vue": "^3.4.27",
"vite": "^2.9.14",
node version: 18.3.0
I'm creating a application and using free PeerJS server to share screen or camera.
while testing, I try to cut one PC's WiFi down and reopen the WiFi after disconnect event is fired. But reconnect only works sometimes.
after I call reconnect, nothing happens. No event, no connect, no error.
the status which PeerJS offer, like open、destory will stay false. Only disconnect will change to false after I call reconnect.
If I try to recoonect it again, the result wont change.
after I open the debug of server, it shows the steps and we can see it's not get the message:
"try to reconnect..."
PeerJS: Attempting reconnection to server with ID ****
PeerJS: Socket open
// end, no next one
it should be like this
"try to reconnect..."
PeerJS: Attempting reconnection to server with ID ****
PeerJS: Socket open
PeerJS: Server message received: { type: 'OPEN' } // we're missing this one
// next: fire the open event
here is my code
let peerConnection = new Peer()
let reconnectInterval: any
peerConnection.on('open', () => {
console.log('open')
if (reconnectInterval) {
window.clearInterval(reconnectInterval)
reconnectInterval = undefined
}
})
peerConnection.on('error', (e) => {
console.error('peer error, error = ' + e)
})
peerConnection.on('disconnected', (e) => {
console.error('peer disconnected, error = ' + e + ', ' + new Date())
if (!reconnectInterval) {
reconnectInterval = setInterval(() => {
if (!peerConnection.destroyed && !peerConnection.open) {
console.log('try to reconnect...')
try {
peerConnection.reconnect()
} catch (e) {
console.error('reconnect error, error = ' + e)
}
}
}, 5000)
}
})
does anyone know about this?
How can we reproduce the issue?
No response
What do you expected to happen?
if can't reconnect, it will fire event to try again, and return evey error or fire event.
Environment setup
- OS: windows 10 / window 11
- Platform: nodeJS, Vue3
- Browser: Chrome 126.0.6478.116 、 Chrome 126.0.6478.63
Is this a regression?
No response
Anything else?
No response