Closed CryptishApps closed 2 years ago
Have you made any progress with this? I have just tried to make a basic app to share data between two devices, its getting the ID, its connecting, but then there is no connection.on('open' event happening that i can see, so no data sent / received etc. I have tried multiple browsers and from a number of different locations (networks and firewall settings) all show the same behaviour.
Cheers
Mark
Yes, my issue was with react-native-peerjs, which the author just solved by releasing 1.0.4. Are you using that?
ah, no just the standard JS library here.
odd, ok thanks it must be something else then.
I think I'm having the same problem. I'm not using any of the react-native-js. I'm trying to follow a tutorial that uses peerjs to share streams to create a simple video chat.
The source is located at: https://github.com/WebDevSimplified/Zoom-Clone-With-WebRTC with the most important code being located in: https://github.com/WebDevSimplified/Zoom-Clone-With-WebRTC/blob/master/public/script.js
When following the tutorial, we launch a PeerJS server on port 3001. When the code is started (using the startDev script), the server is hosted on port 3000. Going to localhost:3000 will generate a new "roomId", which is just a UUID and will reroute the user to: http://localhost:3000/
When a second user attempts to go direct to the room (http://localhost:3000/
None of the PeerJS calls are being invoked and neither of the streams are being sent to each other. The critical piece of code seems to be the following function:
function connectToNewUser(userId, stream) {
timestampConsole("Calling user: "+ userId+" with myStream")
const call = myPeer.call(userId, stream)
const video = document.createElement('video')
call.on('stream', userVideoStream => {
timestampConsole("Call received on stream!");
addVideoStream(video, userVideoStream)
})
call.on('close', () => {
timestampConsole("Called recieved close")
video.remove()
})
peers[userId] = call
}
If I put a break point on line:
const video = document.createElement('video')
and wait a second or two, then all of the events fire correctly and the streams are shared across the steam.
I tried to put a sleep to simulate the breakpoint but that exhibited the broken behavior.
Seems like not PeerJS issue.
Thanks for this awesome bit of work you've put together.
I have an electron/node app running on localhost (laptop) and a react native app running on my mobile (using this)
Both can get an ID from either your server or one that I run locally, no problems there.
Using
peer.call(mobileId, stream);
on my laptop. This ends up triggering themobPeer.on('call', function(call) {
as expected.However, the
call.on('stream', function(stream) {
never gets executed, no matter what I seem to do. Any help would be appreciated.Electron Project (laptop):
React Native code: