Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Cloudflare platform skill covering Workers, D1, R2, KV, AI, Durable Objects, and security.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/turn/README.md
1# Cloudflare TURN Service23Expert guidance for implementing Cloudflare TURN Service in WebRTC applications.45## Overview67Cloudflare TURN (Traversal Using Relays around NAT) Service is a managed relay service for WebRTC applications. TURN acts as a relay point for traffic between WebRTC clients and SFUs, particularly when direct peer-to-peer communication is obstructed by NATs or firewalls. The service runs on Cloudflare's global anycast network across 310+ cities.89## Key Characteristics1011- **Anycast Architecture**: Automatically connects clients to the closest Cloudflare location12- **Global Network**: Available across Cloudflare's entire network (excluding China Network)13- **Zero Configuration**: No need to manually select regions or servers14- **Protocol Support**: STUN/TURN over UDP, TCP, and TLS15- **Free Tier**: Free when used with Cloudflare Calls SFU, otherwise $0.05/GB outbound1617## In This Reference1819| File | Purpose |20|------|---------|21| [api.md](./api.md) | Credentials API, TURN key management, types, constraints |22| [configuration.md](./configuration.md) | Worker setup, wrangler.jsonc, env vars, IP allowlisting |23| [patterns.md](./patterns.md) | Implementation patterns, use cases, integration examples |24| [gotchas.md](./gotchas.md) | Troubleshooting, limits, security, common mistakes |2526## Reading Order2728| Task | Files to Read | Est. Tokens |29|------|---------------|-------------|30| Quick start | README only | ~500 |31| Generate credentials | README → api | ~1300 |32| Worker integration | README → configuration → patterns | ~2000 |33| Debug connection | gotchas | ~700 |34| Security review | api → gotchas | ~1500 |35| Enterprise firewall | configuration | ~600 |3637## Service Addresses and Ports3839### STUN over UDP40- **Primary**: `stun.cloudflare.com:3478/udp`41- **Alternate**: `stun.cloudflare.com:53/udp` (blocked by browsers, not recommended)4243### TURN over UDP44- **Primary**: `turn.cloudflare.com:3478/udp`45- **Alternate**: `turn.cloudflare.com:53/udp` (blocked by browsers)4647### TURN over TCP48- **Primary**: `turn.cloudflare.com:3478/tcp`49- **Alternate**: `turn.cloudflare.com:80/tcp`5051### TURN over TLS52- **Primary**: `turn.cloudflare.com:5349/tcp`53- **Alternate**: `turn.cloudflare.com:443/tcp`5455## Quick Start56571. **Create TURN key via API**: see [api.md#create-turn-key](./api.md#create-turn-key)582. **Generate credentials**: see [api.md#generate-temporary-credentials](./api.md#generate-temporary-credentials)593. **Configure Worker**: see [configuration.md#cloudflare-worker-integration](./configuration.md#cloudflare-worker-integration)604. **Implement client**: see [patterns.md#basic-turn-configuration-browser](./patterns.md#basic-turn-configuration-browser)6162## When to Use TURN6364- **Restrictive NATs**: Symmetric NATs that block direct connections65- **Corporate firewalls**: Environments blocking WebRTC ports66- **Mobile networks**: Carrier-grade NAT scenarios67- **Predictable connectivity**: When reliability > efficiency6869## Related Cloudflare Services7071- **Cloudflare Calls SFU**: Managed Selective Forwarding Unit (TURN free when used with SFU)72- **Cloudflare Stream**: Video streaming with WHIP/WHEP support73- **Cloudflare Workers**: Backend for credential generation74- **Cloudflare KV**: Credential caching75- **Cloudflare Durable Objects**: Session state management7677## Additional Resources7879- [Cloudflare Calls Documentation](https://developers.cloudflare.com/calls/)80- [Cloudflare TURN Service Docs](https://developers.cloudflare.com/realtime/turn/)81- [Cloudflare API Reference](https://developers.cloudflare.com/api/resources/calls/subresources/turn/)82- [Orange Meets (Open Source Example)](https://github.com/cloudflare/orange)83