WebRTC VoIP Calls Integration

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:
Development stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    847
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    451

Integrating VoIP Calls via WebRTC on Website

WebRTC (Web Real-Time Communication) — browser standard for peer-to-peer media streams. Allows organizing audio and video calls directly in browser without plugins. Scenarios: visitor calling support, video consultation, voice chat in game.

WebRTC Call Components

Signaling server — not part of WebRTC standard, implemented separately. Exchanges SDP (Session Description Protocol) and ICE candidates between clients. Usually via WebSocket.

STUN server — helps clients determine external IP and port (NAT traversal). Can use free Google STUN: stun:stun.l.google.com:19302.

TURN server — relay server for cases when direct P2P impossible (symmetric NAT, corporate firewall). Mandatory for production. Recommended coturn.

Basic Two-Browser Call

// ICE server configuration
const configuration = {
    iceServers: [
        { urls: 'stun:stun.l.google.com:19302' },
        {
            urls: 'turn:turn.yourserver.ru:3478',
            username: 'user',
            credential: 'pass'
        }
    ]
};

// Create connection
const pc = new RTCPeerConnection(configuration);

// Capture microphone
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
stream.getTracks().forEach(track => pc.addTrack(track, stream));

// Handle incoming media stream
pc.ontrack = (event) => {
    const remoteAudio = document.getElementById('remote-audio');
    remoteAudio.srcObject = event.streams[0];
};

// Create offer (call initiator)
const offer = await pc.createOffer();
await pc.setLocalDescription(offer);

// Send offer via signaling (WebSocket)
signalingSocket.send(JSON.stringify({
    type: 'offer',
    sdp: offer,
    to: targetUserId
}));

// Handle ICE candidates
pc.onicecandidate = (event) => {
    if (event.candidate) {
        signalingSocket.send(JSON.stringify({
            type: 'ice_candidate',
            candidate: event.candidate,
            to: targetUserId
        }));
    }
};

Signaling Server on Node.js

const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 8080 });

const clients = new Map(); // userId → WebSocket

wss.on('connection', (ws, req) => {
    const userId = extractUserId(req);
    clients.set(userId, ws);

    ws.on('message', (data) => {
        const message = JSON.parse(data);
        const { type, to } = message;

        if (['offer', 'answer', 'ice_candidate'].includes(type)) {
            const target = clients.get(to);
            if (target && target.readyState === WebSocket.OPEN) {
                target.send(JSON.stringify({ ...message, from: userId }));
            }
        }
    });

    ws.on('close', () => clients.delete(userId));
});

Call Functions in React

function CallButton({ targetUserId }) {
    const [callState, setCallState] = useState('idle'); // idle | calling | connected
    const pcRef = useRef(null);

    const startCall = async () => {
        setCallState('calling');
        const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
        pcRef.current = new RTCPeerConnection(configuration);
        stream.getTracks().forEach(t => pcRef.current.addTrack(t, stream));

        // ... (create offer, send via signaling)
    };

    const endCall = () => {
        pcRef.current?.close();
        setCallState('idle');
    };

    return (
        <button onClick={callState === 'idle' ? startCall : endCall}>
            {callState === 'idle' ? '📞 Call' : '❌ End'}
        </button>
    );
}

Connection Quality

  • OPUS codec — standard WebRTC audio codec, good for speech
  • Adaptive bitrate — WebRTC automatically adjusts quality to channel
  • Echo cancellation — built-in to browser (echoCancellation: true in constraints)
  • Noise suppression — likewise built-in

Quality Monitoring

// WebRTC Stats API
const stats = await pc.getStats();
stats.forEach(report => {
    if (report.type === 'inbound-rtp' && report.kind === 'audio') {
        console.log('Jitter:', report.jitter);
        console.log('Packet loss:', report.packetsLost / report.packetsReceived);
        console.log('RTT:', report.roundTripTime);
    }
});

TURN Server (coturn)

# /etc/turnserver.conf
listening-port=3478
tls-listening-port=5349
fingerprint
lt-cred-mech
user=user:password
realm=yourserver.ru

Without TURN about 15–20% calls won't establish due to network restrictions. With TURN — nearly 100%.

Development timeline: 3–5 weeks for complete implementation with signaling server, TURN and call interface.