No connection when hosted, but locally ok
zheniaslius opened this issue · comments
Im getting this error when trying to connect to another peer on another network. Running locally or on the same network everything is fine
config is like this
const config = { iceServers: [{ urls: "stun:stun.l.google.com:19302" }] }
and the rest
` const handlePeer = (peer) => {
peer.on('stream', (currentStream) => {
userVideo.current && (userVideo.current.srcObject = currentStream);
console.log('on stream', currentStream);
});
peer.on('error', () => leaveCall(true));
peer.on('close', () => leaveCall());
connectionRef.current = peer;
};
const answerCall = useCallback(() => {
setCallPending(true);
const peer = new window.SimplePeer({ initiator: false, trickle: false, stream, config });
peer.on('signal', (data) => {
socket.emit('answerCall', { signal: data, to: call.from });
});
peer.signal(call.signal);
handlePeer(peer);
}, [call.from, call.signal, stream, handlePeer])
const callUser = (id) => {
const peer = new window.SimplePeer({ initiator: true, trickle: false, stream, config });
peer.on('signal', (data) => {
socket.emit('callUser', { userToCall: id, signalData: data, from: me });
});
socket.on('callAccepted', (signal) => {
setCallPending(true);
peer.signal(signal);
});
handlePeer(peer);
};`
This is usually because of ice candidates, check in chrome://webrtc-internals/
the ice-matrix and observe how and which ones connect, local peers are different than remote ones.