Development
Popular article

WebRTC in Production: Large-Scale Video Teleconsultation

Wapiki Team
January 25, 2026
12 min read
WebRTCVideoReact NativePerformanceMobile

The Challenge of Video in Africa

Deploying a video teleconsultation solution in Africa presents unique challenges: unstable 3G connection, high latency, and expensive data.

For Keneya, we had to optimize every aspect of our WebRTC stack.

Optimized WebRTC Architecture

1. Optimized TURN/STUN Server

typescript
const configuration: RTCConfiguration = {
  iceServers: [
    { urls: 'stun:stun.wapiki.com:3478' },
    {
      urls: 'turn:turn.wapiki.com:3478',
      username: 'keneya',
      credential: 'secure_token'
    }
  ],
  bundlePolicy: 'max-bundle',
  rtcpMuxPolicy: 'require',
  iceCandidatePoolSize: 10
}

2. Dynamic Quality Adaptation

Our algorithm detects network quality and automatically adjusts:

  • **Excellent connection (4G+)**: 720p, 30fps
  • **Good connection (3G+)**: 480p, 24fps
  • **Weak connection (3G)**: 360p, 15fps
  • **Very weak**: Audio only
  • typescript
    async function adaptVideoQuality(stats: RTCStatsReport) {
      const bandwidth = calculateBandwidth(stats)
    
      if (bandwidth < 500) {
        // Switch to audio only
        await disableVideo()
      } else if (bandwidth < 1000) {
        // 360p, 15fps
        await setVideoConstraints({ width: 640, height: 360, frameRate: 15 })
      } else if (bandwidth < 2000) {
        // 480p, 24fps
        await setVideoConstraints({ width: 854, height: 480, frameRate: 24 })
      } else {
        // 720p, 30fps
        await setVideoConstraints({ width: 1280, height: 720, frameRate: 30 })
      }
    }

    3. Mobile Optimization (React Native)

    On React Native, we use react-native-webrtc with specific optimizations:

  • **VP8** codec for maximum compatibility
  • **Hardware acceleration** on Android/iOS
  • **Automatic echo cancellation**
  • **Background mode** for iOS
  • Reconnection Management

    Network cuts are frequent. Our system automatically reconnects:

    typescript
    peerConnection.oniceconnectionstatechange = async () => {
      if (peerConnection.iceConnectionState === 'disconnected') {
        // ICE restart attempt
        await restartIce()
      } else if (peerConnection.iceConnectionState === 'failed') {
        // Recreate the entire connection
        await recreatePeerConnection()
      }
    }

    Production Results

  • 📊 **25,000+ video consultations** completed
  • ⚡ **Average latency**: 280ms
  • 📱 **Success rate**: 94% on 3G
  • 🔄 **Auto-reconnection**: <3 seconds
  • Conclusion

    WebRTC in Africa is possible, but requires aggressive optimization and deep understanding of network constraints.


    *Developing a real-time video solution? [Let's talk](/contact).*

    Did you like this article?

    Share it with your network!