peers / peerjs

Simple peer-to-peer with WebRTC.
https://peerjs.com
MIT License
12.4k stars 1.43k forks source link

Peerjs video call is not working on live server #776

Open pouyapanahandeh opened 3 years ago

pouyapanahandeh commented 3 years ago

Hi everyone,

I built a simple video call service but it's not working, it was working on localhost and after I deployed it on Heroku it stops working. you can check the service here: https://moon-call.herokuapp.com/ when you open the link it will generate id and you can share this id with someone and start talking to each other. you can see the project source code here: https://github.com/pouyapanahandeh/moon

would be great if you can help me to solve this problem, thanks in advance

AlvaroHerrero commented 3 years ago

Are you getting the MediaStream object? I am having a similar issue, the Stream is returned un the event but no audio (in this case) in It.

onadrog commented 3 years ago

Try this it work for me on heroku:

const peer = new Peer({
    key: 'peerjs',
    host: 'yourHerokuHostName.com',
    port: 443,
    path: '/',
    secure: true,
})

In your code you just provide 'host' and 'secure' options that's maybe why, and let the server give a uuid instead of writing 'undefined'. Hope it helps.

ps: i'm using PeerJs Server Buttons for PeerJs server

pouyapanahandeh commented 3 years ago

Are you getting the MediaStream object? I am having a similar issue, the Stream is returned un the event but no audio (in this case) in It.

Do you get the video on both sides?

pouyapanahandeh commented 3 years ago

Try this it work for me on heroku:

const peer = new Peer({
    key: 'peerjs',
    host: 'yourHerokuHostName.com',
    port: 443,
    path: '/',
    secure: true,
})

In your code you just provide 'host' and 'secure' options that's maybe why, and let the server give a uuid instead of writing 'undefined'. Hope it helps.

ps: i'm using PeerJs Server Buttons for PeerJs server

I tried your solution, still is not working

onadrog commented 3 years ago

Weird, maybe try to check this 2 things. Did you have the socket connection open 'using evt ?

peer.on('open', id => concole.log(id))

According to MDN docs a MediaStream must us secure connection see 'Encryption based security' if you're using it on your local enviroment use something like mkcert to have encryption on your local env.

NdubuisiJr commented 3 years ago

I have the same problem. I received the media stream on both sides. The video elements are added to the dom but he video doesn't show up

pouyapanahandeh commented 3 years ago

I have the same problem. I received the media stream on both sides. The video elements are added to the dom but he video doesn't show up

did you find any solution?

tejasthakaregit commented 3 years ago

Ok I am facing something really weird. My both user are get connected when they are in same wifi or same hotspot. But if I change the network (wifi, hotspot) only video sector is visible but not get connected.

tejasthakaregit commented 3 years ago

Here is my hosting

https://gentle-castle-05941.herokuapp.com/9ea7af70-ab0c-4d89-a06f-e8b6d0888fac

Wait for server to start and then allow camera and audio.

punquz commented 3 years ago

Did anyone manage to solve this? My video chat app was working perfectly fine, but now it's not working, If I am running on the same wifi, it works, but does not work if I ask my friend to join from a different network.

alialkorsani commented 3 years ago

@punquz you should add ICE servers to your config

vaidehi44 commented 3 years ago

Hello. I am facing the same issue. Video streams don't show up on both sides. Can someone please tell me the exact solution for this. It would be really helpful.

punquz commented 3 years ago

@vaidehi44 You need to have your own turn server, I have hosted my own turn server in EC2. use this link, https://gabrieltanner.org/blog/turn-server

vaidehi44 commented 3 years ago

@vaidehi44 You need to have your own turn server, I have hosted my own turn server in EC2. use this link, https://gabrieltanner.org/blog/turn-server

Okay. Thanks.