How to avoid echo in webrtc?

I need to implement simple peer to peer video calling app.

I use the next simple example.

When I run it locally and open web page on my MacBook / iPhone it has echo. I hear what I just told. Even before starting a call.

I record audio and quality is terrible:

const chunks = [];
navigator.mediaDevices.getUserMedia({ audio: true, video: false }).then(handleSuccess);
const handleSuccess = function (stream) {
    const mediaRecorder = new MediaRecorder(stream);
    mediaRecorder.addEventListener('dataavailable', (event) => {
        chunks.push(event.data);
        sendData(event.data);
    });
};

I tried the next code but it did not help:

const pc = new RTCPeerConnection(servers);
pc.setConfiguration({echoCancellation: true});
pc.setConfiguration({noiseSuppression: true, autoGainControl: true});

How to remove echo? Should I use separate lib for that?