Closed Tomas-M closed 5 years ago
What browsers are you using?
(In the either direction, your connection.open
is true, right?
Browser is Google Chrome 37.0.2062.120 (Official Build 281580) m - on both sides the same browser. In one direction, connection.open is false and the on(open) is not called. In other direction, the connection.open is true and on(open) is called.
@michelle Do you have any updates on this issue?
I have the same situation. The connection is on both sides open. But the open function wasn't triggered on one browser.
The same in 2017. You need to play with kind of flags/timeouts/negotiation to avoid a data flow before the connection is established.
i think it's already fixed. Let me know if it happens again.
Hello, i'm facing a similar issue
@lagcamgc are you using the latest version 1.0.0? Do you mean peer's event or mediaConnection's event?
same here..... just bit different:
@lagcamgc are you using the latest version 1.0.0? Do you mean peer's event or mediaConnection's event?
mediaConnection open status for one of the sides is false and the other one true, also one of the sides is not entering on the peer.on('connection'... And yes i'm using the latest version
There is no 'open' event for mediaConnection https://peerjs.com/docs.html#mediaconnection-on initiator side: open = true after create a call another side: open = true after answer the call
But we can add it
peer.on('connection')
(and peer.on('call')
) executes on callee's side only.
There is no 'open' event for mediaConnection https://peerjs.com/docs.html#mediaconnection-on initiator side: open = true after create a call another side: open = true after answer the call
But we can add it
peer.on('connection')
(andpeer.on('call')
) executes on callee's side only.
Sorry the actual piece of code is this one, and i'm talking about the open status, the boolean:
Object.keys(members).forEach(memberUid => {
connections.push(peer.connect(memberUid))
peer.on('connection', (conn) => {
console.log('Connection done...')
connectionsOpened.push(conn)
// here we can receive data from each connection
conn.on('data', (data) => {
// actualizar store
console.log('Data comming...')
console.log(data)
})
})
})
Also when you say
executes on callee's side only.
You mean only one side detects the connection? Also i tried this:
Object.keys(members).forEach(memberUid => {
let conn = peer.connect(memberUid)
connections.push(conn)
// here we can receive data from each connection
conn.on('data', (data) => {
console.log('Data comming...')
console.log(data)
})
})
And it also does not get there
The problem is that the open status for mediaConnection is not being updated on one of the sides and that the on('connection') is being triggered on one of the sides only
If the on('connection') is intended to be triggered just on one of the sides then i can not communicate in a duplex way?
Could you please check my example https://gist.github.com/afrokick/06f30a550008132c4aa5cf3fe987238d
Is it work for you?
Could you please check my example https://gist.github.com/afrokick/06f30a550008132c4aa5cf3fe987238d
Is it work for you?
Actually no, it's weird, i make work my code putting more listeners
// block 1
connection.on('open', () => {
console.log('Connection done...')
// here we can receive data from each connection
connection.on('data', (data) => {
console.log('Data comming...')
console.log(data)
console.log(data.url)
})
})
// block 2
peer.on('connection', (conn) => {
connections.push(conn)
console.log('Connection 2 done...')
// here we can receive data from each connection
conn.on('data', (data) => {
console.log('Data 2 comming...')
console.log(data.url)
})
})
Is entering in the on data of the block 1 but if i remove block 2 and save the connection in the block 1 it does not work
Could you please provide a test repo with your code? I'll review it and give you a more precision answer.
Could you please provide a test repo with your code? I'll review it and give you a more precision answer.
Hello sorry for the delay i have been working and actually it was a flow problem Thanks for your help
Also i'm wondering something, just a quick question: if i need multiple instances of peerjs server do someone already handle that because if i'm going to manage thousands of users i think that just one peerjs server can not handle it, is there someone that designed an orchestrator or a gateway to communicate the servers or do you have a suggestion about it?
You are ok with just one instance. PeerServer is in charge of establish the communication only, then everything is Peer to Peer (server does nothing after the initial communication setup)
Think about horizontal scalation when you reach a few million users.
@lagcamgc can you please describe what kind of flow problem that was? I am fighting the same problem right now, it used to work flawlessly with pre v1, but now on fast networks connection works perfectly but on remote a bit slower ones, a connection is fired on one peer, but "open" isn't being fired on the other, the one that has connected.
@maxpavlov hello sorry for not replying in a lot of time, you still having the issue?if so please let me know to look at my previous code
Please open new issue if it still exists in 1.0.4+ version
Been stuck with this issue.
call.open remains false
console.log(
New peer [${userId}] sent request.`)
const conn = peer.connect(userId)
setTimeout(() => {
console.log('Tried to connect to', userId, conn.open)
}, 5000)
conn.on('open', () => {
console.log(`Connection established with peer [${userId}].`)
// once peer connection established
allPeers.add(userId)
// introduce yourself to the new member
conn.send({'event': 'init', 'userId': myUserId})
// try to call with stream
// originally, the pre-existing members will try to take responsibility of calling
if (myStream !== null) {
callWithStream(userId)
} else {
console.log("Call was not made since stream not available.")
}
})`
When I test things locally in multiple tabs, everything seems to work just fine. But when I test with friend who is in different network, I noticed a problem. When my computer is the original peer (server) and connection is opened (received) from my friends computer (client), it looks OK on my side, but the conn.open flag remains false on my friends computer (client) even if the connection was successful. The problem is that in this state the conn.on('open') is never called on the client.
It is probably something related to network, since if we try it in opposite direction (my friend is initial peer and I am client peer), then it works just fine and conn.on('open') gets called properly.
FYI, the on('error') shows nothing neither for conn nor for peer (is never called). Maybe a bug...