Comments (8)
When a client disconnects, it automatically tries to reconnnect. Are you sure that the client is disconnected when added:webrtc:[98ee6477-5037-49ee-bd20-b8f69928dade]
is fired?
from y-webrtc.
Yes.
When I review y-webrtc for the close, (this.peer.on('close', () =>...) the last line is announceSignalingInfo(room) which triggerS:
const announceSignalingInfo = room => {
signalingConns.forEach(conn => {
// only subcribe if connection is established, otherwise the conn automatically subscribes to all rooms
if (conn.connected) {
conn.send({ type: 'subscribe', topics: [room.name] })
if (room.webrtcConns.size < room.provider.maxConns) {
publishSignalingMessage(conn, room, { type: 'announce', from: room.peerId })
}
}
})
}
there's the debugs you're seeing. 'true' is conn.connected. So on close, it's announcing signically messages, even though it's closing.
My naive understanding suggests it shouldn't be announcing or, this shouldn't say 'added' from the message :
const emitPeerChange = webrtcConns.has(data.from) ? () => {} : () =>
room.provider.emit('peers', [{
removed: [],
added: [data.from],
webrtcPeers: Array.from(room.webrtcConns.keys()),
bcPeers: Array.from(room.bcConns)
}])
from y-webrtc.
There are three types of connections. 1. There are WebRTC connections. The line you mentioned this.peer.on('close', () =>...)
is referring to a webrtc conenction. 2. There are BroadcastChannel connections (connections to other peers in the same browser are not handled via WebRTC). 3. There are Websocket connections to a signaling server. announceSignalingInfo
sends a message to the websocket/signaling server. When a WebRTC connection closes unexpectedly, we announce ourselves over the signaling server again to reconnect to the closed connection. After a time, the remote client reconnects (either using 1. WebRTC or via 2. BroadcastChannel) and the peers: {added: [..]}
event is fired.
from y-webrtc.
alright, what I'm seeing:
this.peer.on('close', () => {
this.connected = false
this.closed = true
if (room.webrtcConns.has(this.remotePeerId)) {
room.webrtcConns.delete(this.remotePeerId)
room.provider.emit('peers', [{
removed: [this.remotePeerId],
added: [],
webrtcPeers: Array.from(room.webrtcConns.keys()),
bcPeers: Array.from(room.bcConns)
}])
}
checkIsSynced(room)
this.peer.destroy() ***// should this just be 'this.destroy'***
log('closed connection to ', logging.BOLD, remotePeerId)
announceSignalingInfo(room)
})
the announceSignalingInfo call triggers the announcement and the second client gets a 'peers' notification as the peer being added.
It's possible it's a race condition since I'm just doing it locally between two browsers or it's something stranger with the devserver updating.
from y-webrtc.
How do you close the connection to the remote client?
from y-webrtc.
refresh the browser -> close is triggered
If it was re-logging in, we'd have a different peerId, but the same peer ID shows up on the second client. That's the log that's shown on the second browser window, which I retested just so:
removed:webrtc:[11064215-ac2b-48e2-bfd8-52966676e517] WebrtcProvider {…}
y-webrtc.js?9b73:270 announceSignalingInfo Room {…} true
...
y-webrtc.js?9b73:270 announceSignalingInfo Room {…} true
...
y-webrtc.js?9b73:270 announceSignalingInfo Room {…} true
eval @ y-webrtc.js?9b73:270
announceSignalingInfo @ y-webrtc.js?9b73:265
eval @ y-webrtc.js?9b73:221
r.emit @ simplepeer.min.js?07cd:6
eval @ simplepeer.min.js?07cd:6
error (async)
_setupData @ simplepeer.min.js?07cd:6
p @ simplepeer.min.js?07cd:6
WebrtcConn @ y-webrtc.js?9b73:183
eval @ y-webrtc.js?9b73:501
setIfUndefined @ map.js?4b35:49
execMessage @ y-webrtc.js?9b73:501
Promise.then (async)
eval @ y-webrtc.js?9b73:515
eval @ observable.js?9732:73
emit @ observable.js?9732:73
websocket.onmessage @ websocket.js?49e4:45
y-webrtc.js?9b73:491 {type: "announce", from: "11064215-ac2b-48e2-bfd8-52966676e517"} "11064215-ac2b-48e2-bfd8-52966676e517"
emitPeerChange @ y-webrtc.js?9b73:491
execMessage @ y-webrtc.js?9b73:502
Promise.then (async)
eval @ y-webrtc.js?9b73:515
eval @ observable.js?9732:73
emit @ observable.js?9732:73
websocket.onmessage @ websocket.js?49e4:45
SyncPeers.js?a801:235
added:webrtc:[11064215-ac2b-48e2-bfd8-52966676e517]
WebrtcConn {room: Room, remotePeerId: "11064215-ac2b-48e2-bfd8-52966676e517", closed: false, connected: false, synced: false, …} WebrtcProvider {…}
from y-webrtc.
It's possible it's a race condition since I'm just doing it locally between two browsers or it's something stranger with the devserver updating.
This is probably the reason. A devserver often duplicates created objects. Sorry, it is impossible for me to debug this issue. Unless you provide a step-by-step example for how I can reproduce this (without some react dev-server setup) I can't help you.
Can you maybe create a simple project (maybe fork https://github.com/yjs/yjs-demos) and describe the steps to reproduce this issue?
from y-webrtc.
it appears to be chrome specific. I upgraded the demo here:
https://github.com/disarticulate/y-webrtc/tree/master/demo
Reproduce:
- open 2 chrome threads (not in same window):
/usr/bin/chromium-browser --user-data-dir=$root/chrome1 --password-store=basic http://localhost:8080/demo/ &
/usr/bin/chromium-browser --user-data-dir=$root/chrome2 --password-store=basic http://localhost:8080/demo/ &
-
open a firefox browser (just to double check)
-
wait till
added:webrtc:[peerId]
-
close chrome or refresh chrome
-
observe console:
removed:webrtc:[fb8ba1ec-759c-4b57-a6d5-fb5f9a19b780] index.js:13:12
synced!
Object { synced: false }
index.js:25:10
Object { _readableState: {…}, readable: true, _events: {…}, _eventsCount: 2, _maxListeners: undefined, _writableState: {…}, writable: true, allowHalfOpen: false, _id: "f240014", channelName: "7a260e731074938719ec8719f2e19adf96eb1458", … }
SimplePeerExtended.js:44:12
added:webrtc:[fb8ba1ec-759c-4b57-a6d5-fb5f9a19b780]
You may want to use the standard SimplePeer if you think I did something untoward to it.
I'll comment on the rest of that code in the other issue I've got open #20
from y-webrtc.
Related Issues (20)
- TypeError: Cannot read property 'encrypt' of undefined HOT 2
- Issues in trying to use `y-webrtc` : WebSocket is not defined : node_modules/lib0/websocket.js:25:23
- Over-strict type declaration for the options of WebRtcProvider
- Explore options for smaller footprint, browser-based webrtc clients HOT 6
- Library fails with missing global declarations when run inside nodejs (ES6) HOT 5
- Use Authentication for allowing/blocking access HOT 1
- Reactive "connected" property HOT 6
- Error when updating text field with long string HOT 1
- public signaling servers down? HOT 10
- add STUN/TURN servers after the provider is made HOT 6
- Error: A Yjs Doc connected to room "#room-name" already exists HOT 1
- Allow for or extend checking connectedness of the provider HOT 1
- y-webrtc doesn't work on different browsers HOT 3
- emit 'sync' HOT 1
- Use existing (3rd party) signaling server implementation HOT 1
- Problem with firefox and y-webrtc HOT 4
- Error message on Firefox: WebRTC: ICE failed, add a TURN server and see about:webrtc for more details HOT 1
- API modifications proposal
- The editor content does not sync on different browsers HOT 4
- Emit events when the connected state changes HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from y-webrtc.