why my simple-peer app doesn't work on server

815 views Asked by At

i have reactjs build in my server side and im rendering it when get requests on '/*'.

my problem is when i make calls in localhost it works but when i get a build of project and run it on server sometimes my stream call video does not reach to receiver for example sometimes it works on another laptop on wifi but not works a mobile phone with wifi nor cellular data.

Can it be about serving react app like this or this is a problem about my code

i also added stun/turn servers from numb.viagenie.ca but it still same

how can i solve it ?

here is code part when user make call:

var peer = new Peer({
    initiator:true,
    trickle:true,
    iceTransportPolicy: 'relay',
    stream:uStream,
    offerConstraints: { 
        offerToReceiveAudio: true, 
        offerToReceiveVideo: true 
    },
    config: {
        iceServers: [
            {
                urls: "stun:numb.viagenie.ca",
            },
            {
                urls: "turn:numb.viagenie.ca",
                username: "username",
                credential: "password"
            }
        ]
    }
});
peer.on('signal', signal => {
    console.log('Call Signal', signal);
    socket.emit('call', { signal, receiver_id: user.id, room_id:roomID, caller_username:username });
});

here is code part when user receive call:

var peer = new Peer({
    initiator:false,
    trickle:true,
    answerConstraints: { 
        offerToReceiveAudio: false, 
        offerToReceiveVideo: false 
    }
});
peer.on('signal', signal => {
    console.log('Answer Signal', signal);
    socket.emit('answer', { signal, room_id:roomID, receiver_username:username, caller_username:incomingCall.caller_username });
});
peer.signal(incomingCall.signal);

thanks.

1

There are 1 answers

2
omer98 On

I solved my problem with creating my own TURN/STUN servers with coturn. I guess there were some problems with other servers.