feross / feross/simple-peer

No connection when hosted, but locally ok

Open
#911 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.8k
Forks
983
PR merge metrics
No merged PRs in 30d

Description

Im getting this error when trying to connect to another peer on another network. Running locally or on the same network everything is fine

![Screenshot 2023-01-11 at 22 13 36](https://user-images.githubusercontent.com/26329364/211908302-add2f6eb-db00-446a-b40b-06302397b4ac.png)

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);
};`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.