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/realtimekit/gotchas.md
1# RealtimeKit Gotchas & Troubleshooting23## Common Errors45### "Cannot connect to meeting"67**Cause:** Auth token invalid/expired, API credentials lack permissions, or network blocks WebRTC8**Solution:**9Verify token validity, check API token has **Realtime / Realtime Admin** permissions, enable TURN service for restrictive networks1011### "No video/audio tracks"1213**Cause:** Browser permissions not granted, video/audio not enabled, device in use, or device unavailable14**Solution:**15Request browser permissions explicitly, verify initialization config, use `meeting.self.getAllDevices()` to debug, close other apps using device1617### "Participant count mismatched"1819**Cause:** `meeting.participants` doesn't include `meeting.self`20**Solution:** Total count = `meeting.participants.joined.size() + 1`2122### "Events not firing"2324**Cause:** Listeners registered after actions, incorrect event name, or wrong namespace25**Solution:**26Register listeners before calling `meeting.join()`, check event names against docs, verify correct namespace2728### "CORS errors in API calls"2930**Cause:** Making REST API calls from client-side31**Solution:** All REST API calls **must** be server-side (Workers, backend). Never expose API tokens to clients.3233### "Preset not applying"3435**Cause:** Preset doesn't exist, name mismatch (case-sensitive), or participant created before preset36**Solution:**37Verify preset exists via Dashboard or API, check exact spelling and case, create preset before adding participants3839### "Token reuse error"4041**Cause:** Reusing participant tokens across sessions42**Solution:** Generate fresh token per session. Use refresh endpoint if token expires during session.4344### "Video quality poor"4546**Cause:** Insufficient bandwidth, resolution/bitrate too high, or CPU overload47**Solution:**48Lower `mediaConfiguration.video` resolution/frameRate, monitor network conditions, reduce participant count or grid size4950### "Echo or audio feedback"5152**Cause:** Multiple devices picking up same audio source53**Solution:**54- Lower `mediaConfiguration.video` resolution/frameRate55- Monitor network conditions56- Reduce participant count or grid size5758### Issue: Echo or audio feedback59**Cause**: Multiple devices picking up same audio source6061**Solutions**:62Enable `echoCancellation: true` in `mediaConfiguration.audio`, use headphones, mute when not speaking6364### "Screen share not working"6566**Cause:** Browser doesn't support screen sharing API, permission denied, or wrong `displaySurface` config67**Solution:**68Use Chrome/Edge/Firefox (Safari limited support), check browser permissions, try different `displaySurface` values ('window', 'monitor', 'browser')6970### "How do I schedule meetings?"7172**Cause:** RealtimeKit has no built-in scheduling system73**Solution:**74Store meeting IDs in your database with timestamps. Generate participant tokens only when user should join. Example:75```typescript76// Store in DB77{ meetingId: 'abc123', scheduledFor: '2026-02-15T10:00:00Z', userId: 'user456' }7879// Generate token when user clicks "Join" near scheduled time80const response = await fetch('/api/join-meeting', {81method: 'POST',82body: JSON.stringify({ meetingId: 'abc123' })83});84const { authToken } = await response.json();85```8687### "Recording not starting"8889**Cause:** Preset lacks recording permissions, no active session, or API call from client90**Solution:**91Verify preset has `canRecord: true` and `canStartStopRecording: true`, ensure session is active (at least one participant), make recording API calls server-side only9293## Limits9495| Resource | Limit |96|----------|-------|97| Max participants per session | 100 |98| Max concurrent sessions per App | 1000 |99| Max recording duration | 6 hours |100| Max meeting duration | 24 hours |101| Max chat message length | 4000 characters |102| Max preset name length | 64 characters |103| Max meeting title length | 256 characters |104| Max participant name length | 256 characters |105| Token expiration | 24 hours (default) |106| WebRTC ports required | UDP 1024-65535 |107108## Network Requirements109110### Firewall Rules111Allow outbound UDP/TCP to:112- `*.cloudflare.com` ports 443, 80113- UDP ports 1024-65535 (WebRTC media)114115### TURN Service116Enable for users behind restrictive firewalls/proxies:117```jsonc118// wrangler.jsonc119{120"vars": {121"TURN_SERVICE_ID": "your_turn_service_id"122}123// Set secret: wrangler secret put TURN_SERVICE_TOKEN124}125```126127TURN automatically configured in SDK when enabled in account.128129## Debugging Tips130131```typescript132// Check devices133const devices = await meeting.self.getAllDevices();134meeting.self.on('deviceListUpdate', ({ added, removed, devices }) => console.log('Devices:', { added, removed, devices }));135136// Monitor participants137meeting.participants.joined.on('participantJoined', (p) => console.log(`${p.name} joined:`, { id: p.id, userId: p.userId, audioEnabled: p.audioEnabled, videoEnabled: p.videoEnabled }));138139// Check room state140meeting.self.on('roomJoined', () => console.log('Room:', { meetingId: meeting.meta.meetingId, meetingTitle: meeting.meta.meetingTitle, participantCount: meeting.participants.joined.size() + 1, audioEnabled: meeting.self.audioEnabled, videoEnabled: meeting.self.videoEnabled }));141142// Log all events143['roomJoined', 'audioUpdate', 'videoUpdate', 'screenShareUpdate', 'deviceUpdate', 'deviceListUpdate'].forEach(event => meeting.self.on(event, (data) => console.log(`[self] ${event}:`, data)));144['participantJoined', 'participantLeft'].forEach(event => meeting.participants.joined.on(event, (data) => console.log(`[participants] ${event}:`, data)));145meeting.chat.on('chatUpdate', (data) => console.log('[chat] chatUpdate:', data));146```147148## Security & Performance149150### Security: Do NOT151- Expose `CLOUDFLARE_API_TOKEN` in client code, hardcode credentials in frontend152- Reuse participant tokens, store tokens in localStorage without encryption153- Allow client-side meeting creation154155### Security: DO156- Generate tokens server-side only, use HTTPS, implement rate limiting157- Validate user auth before generating tokens, use `custom_participant_id` to map to your user system158- Set appropriate preset permissions per user role, rotate API tokens regularly159160### Performance161- **CPU**: Lower video resolution/frameRate, disable video for audio-only, use `meeting.participants.active` for large meetings, implement virtual scrolling162- **Bandwidth**: Set max resolution in `mediaConfiguration`, disable screenshare audio if unneeded, use audio-only mode, implement adaptive bitrate163- **Memory**: Clean up event listeners on unmount, call `meeting.leave()` when done, don't store large participant arrays164165## In This Reference166- [README.md](README.md) - Overview, core concepts, quick start167- [configuration.md](configuration.md) - SDK config, presets, wrangler setup168- [api.md](api.md) - Client SDK APIs, REST endpoints169- [patterns.md](patterns.md) - Common patterns, React hooks, backend integration170