I am creating a video call application using webrtc, peerjs, and socket.io. Everything works well locally until I push and deploy to vercel.
The peer.on("open")
doesn't even get triggered, tried with my server and the peer cloud server too
This is my connection code
peer = new Peer({
host: 'test-api.iludate-agentur.com',
port: 443,
path: '/peerjs',
secure: true,
config: {
iceServers
}
});
I also tried using just
peer = new Peer()
They both work locally but not when deployed
This is my peer.on("open")
code
peer.on('open', async (id) => {
console.log('Here');
// Join room
socket.emit('join-room', bookingId, id);
// Answer call
peer.on('call', (call) => {
call.answer(localStream);
call.on('stream', (stream) => {
remoteStream = stream;
remotePlayer.srcObject = stream;
remotePlayer.play();
});
});
});
This doesn't even get fired at all
Note: All of this work until I deploy to vercel
I was previously using the peer cloud server and thought it wouldn't work on https
. So i deployed my own peer server, the elastic beanstalk load balancer has ssl configured already so i didn't bother doing the ssl code on my end anymore
This is what the server code looks like on my end
// Set up peer server
const peerServer = ExpressPeerServer(app.getHttpServer(), {
path: '/',
allow_discovery: true,
});
app.use('/peerjs', peerServer);