peers / peerjs-server

Server for PeerJS
https://peerjs.com
MIT License
4.36k stars 1.09k forks source link

The call's stream event never fires. #156

Closed CryptishApps closed 4 years ago

CryptishApps commented 4 years ago

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 the mobPeer.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):

let mobileId = doc.data().mobileId;
let conn = webPeer.connect(mobileId);
conn.on('open', function() {

    const call = webPeer.call(mobileId, stream);

    call.on('stream', function(mobStream){
        console.log("Got null stream", mobStream)
    });
});

React Native code:

const mobPeer = new Peer({
    host: ipv4, secure: false, port: 8090, path: '/peer',
});

mobPeer.on('error', function(err) {
    console.log("MOB CONN ERROR", err);
})

mobPeer.on('open', function(id) {
    console.log("mobile id", id)
    // I send ID to database here for electron app to find
});

mobPeer.on('call', function(call) {
    console.log("Web calling"); // this works fine

    call.answer(null);
    call.on('stream', function(stream) {
        console.log('stream from desktop') // this never runs
    });
});
CryptishApps commented 4 years ago

Wrong project - sorry. Added to peerjs instead of the server project.