OpenAICloudflare Developer PlatformMay 29, 2026, 12:00 AM

Realtime - Cloudflare's Realtime WebSocket adapter now auto-reconnects and buffers WebRTC media

A condensed section focused on the key takeaways first.

Original Post

Quick Digest

Summary

A condensed section focused on the key takeaways first.

openaienmodel: gpt-5-mini-2025-08-07

Realtime - Cloudflare's Realtime WebSocket adapter now auto-reconnects and buffers WebRTC media

Key Points

  • Automatic 5s WebSocket retry
  • Audio and video buffered during brief disconnects
  • No API change; adapter closes after 5s if endpoint stays down

Summary

Cloudflare Realtime SFU's WebSocket adapter (Stream/egress mode) now automatically retries a disconnected WebSocket endpoint for up to 5 seconds and buffers live WebRTC media so audio and video can resume without your application having to recreate the adapter. No API changes are required.

Key Points

  • Auto-reconnect: the SFU retries the same WebSocket endpoint for up to 5 seconds after brief disconnects or endpoint restarts.
  • No API change: the adapter will automatically attempt reconnection; if the endpoint remains unavailable after 5 seconds the adapter closes and must be recreated by your app.
  • Audio buffering: uses a short bounded backlog to reduce audible loss; older audio may be dropped if interruption exceeds the backlog.
  • Video buffering: uses live-first buffering and resumes from the latest JPEG frame instead of replaying stale frames.
  • Payloads: adapter streams PCM audio frames and JPEG video frames to standard WebSocket endpoints (useful for transcription, recording, and media processing pipelines).

Recommendations for engineers

  • Ensure backend endpoints restart quickly (<5s) or implement logic to recreate the adapter if needed.
  • Make downstream processing idempotent and tolerant of dropped audio frames or frame gaps.
  • Monitor adapter lifecycle and reconnect events to surface long interruptions that exceed the 5s window.

Full Translation

Translations

A translation section that keeps the flow of the original article.

openaijamodel: gpt-5-mini-2025-08-07

Realtime - CloudflareのRealtime WebSocketアダプタが自動再接続およびWebRTCメディアのバッファリングに対応

CloudflareのRealtime WebSocketアダプタが自動再接続とWebRTCメディアのバッファリングを行うようになりました

公開日: 2026-05-29

概要

Cloudflare Realtime SFUは、Cloudflareのグローバルネットワーク上で動作するWebRTC Selective Forwarding Unit(SFU)で、SFUインフラやリージョンを管理することなく、WebRTCクライアント間でライブ音声、ビデオ、データをルーティングできます。

今回、WebRTCメディアをWebSocketエンドポイントへストリームするために使用されるWebSocket adapterが、短時間のエンドポイント切断や再起動後に自動で再接続し、音声およびビデオをバッファするようになりました。

WebSocketエンドポイントへのWebRTCメディアのストリーミング

多くのチームは、Realtime SFUをバックエンドアプリケーションのメディア層(transcription、recording、note-taking、エージェント型メディア処理サービスなど)として利用しています。これらのシステムは、Durable Objects、Workers、Containers、または外部サービス上のバックエンドインフラで、SFUからのライブWebRTC音声やビデオを自分でWebRTCクライアントを実行せずに消費する必要があることが多いです。

WebSocket adapterはこのギャップを埋め、SFUから標準的なWebSocketエンドポイントへアプリケーションで扱えるペイロード(PCM audio framesやJPEG video frames)としてWebRTCメディアをストリームします。

変更点

  • Stream mode (egress)でSFUから自分のWebSocketエンドポイントへライブ音声やビデオを送る場合、SFUが短時間のエンドポイント切断や再起動後に自動的に再接続するようになりました。
    • これは、録音、文字起こし、ライブ解析などの長時間稼働するメディアパイプラインで、WebSocketエンドポイントが短時間再起動する可能性がある場合に特に役立ちます。
  • 以前は、WebSocketエンドポイントの短時間の切断によってアダプタが閉じられ、メディアが再開する前にアプリケーション側でアダプタを再作成する必要がありました。
  • 現在はAPIの変更なしに、SFUが同じエンドポイントへ最大5秒間リトライします。エンドポイントがそのウィンドウ内に復帰すれば、音声とビデオの配信は自動的に再開します。
  • 再接続の挙動には live-first media buffering(ライブファーストメディアバッファリング)も含まれており、短時間の中断でも古いビデオを再生せずにメディア損失を軽減します。

再接続時の挙動

  • 音声: 可聴損失を低減するために短い有界バックログ(backlog)を使用します。中断がバックログでカバーできる時間を超えると、古い音声は破棄される可能性があります。
  • ビデオ: 古いフレームを再生するのではなく、利用可能な最新のJPEGフレームから再開します。
  • 回復はベストエフォートで行われ、ギャップレスやExactly-once deliveryを保証するものではありません。
  • エンドポイントが5秒の再接続ウィンドウを超えて利用不可のままの場合、アダプタはクローズされ、再作成が必要です。

補足 / 参考

  • WebSocket adapter
  • Automatic reconnection for streaming
  • Get started with Realtime SFU
  • Realtime SFU example architecture
  • Realtime vs Regular SFUs
  • Global SFU Network Visualization ↗

このアップデートにより、長時間稼働するメディアパイプラインにおける短時間のエンドポイント障害による中断が大幅に軽減されます。