Search code examples
javascriptwebrtc

Can't hear peer's voice in a simple audio only WebRTC call with Node.js (WebSockets) and Javascript (WebRTC)


I set up a pretty simple audio call test utilizing WebRTC based off of another one of my projects, a video chat (also using WebRTC). I thought it would be easy, but once I got it set up, the audio isn't played by the user. That means that both peers receive the respective offer/answer SDP WebSocket event, and the SDP is present, but I cannot hear my voice echo back at me when I talk or make any noise. Their is nothing in my console (I catch all errors, too).

Is their a cause for this?

I based my code off of Amir Sanni's video chat located here. I basically just used getUserAudio instead of media stream, and deleted the lines where it added a video.


Solution

  • You will need to play the audio back somehow. I would recommend using audio tags instead of video ones and hiding them with display: none.