|
| 1 | +# Local Jitsi Setup with Recording |
| 2 | + |
| 3 | +This directory contains a complete local Jitsi Meet setup with automatic recording capabilities and event collection. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | + |
| 9 | +1. **Docker** and **Docker Compose** installed |
| 10 | +2. **Node.js** and **npm** for event collector |
| 11 | +3. **mkcert** for SSL certificates (install with `brew install mkcert`) |
| 12 | +4. **Add to /etc/hosts:** |
| 13 | + ```bash |
| 14 | + echo "127.0.0.1 jitsi.local" | sudo tee -a /etc/hosts |
| 15 | + ``` |
| 16 | + |
| 17 | +### Setup SSL Certificates |
| 18 | + |
| 19 | +```bash |
| 20 | +cd ssl |
| 21 | +mkcert jitsi.local localhost 127.0.0.1 ::1 |
| 22 | +cp jitsi.local+3.pem jitsi.crt |
| 23 | +cp jitsi.local+3-key.pem jitsi.key |
| 24 | +``` |
| 25 | + |
| 26 | +### Start Services |
| 27 | + |
| 28 | +```bash |
| 29 | +# Start all Jitsi services (includes event collector) |
| 30 | +docker compose -f docker-compose.simple.yml up -d |
| 31 | +``` |
| 32 | + |
| 33 | +**All services start automatically including:** |
| 34 | +- Jitsi stack (nginx, web, prosody, jicofo, jvb, jibri) |
| 35 | +- Redis database |
| 36 | +- Event collector (containerized) |
| 37 | + |
| 38 | +### Verify Services Running |
| 39 | + |
| 40 | +```bash |
| 41 | +docker ps --filter name=jitsi |
| 42 | +``` |
| 43 | + |
| 44 | +You should see: |
| 45 | +- `jitsi_nginx` (ports 80, 443) |
| 46 | +- `jitsi_web` |
| 47 | +- `jitsi_prosody` |
| 48 | +- `jitsi_jicofo` |
| 49 | +- `jitsi_jvb` (ports 4443, 10000) |
| 50 | +- `jitsi_jibri` (recording service) |
| 51 | +- `jitsi_redis` (port 6380) |
| 52 | +- `jitsi_event_collector` (port 3002) |
| 53 | + |
| 54 | +## Testing |
| 55 | + |
| 56 | +### Test Jitsi Meeting |
| 57 | + |
| 58 | +1. **Start Frontend** (if not already running): |
| 59 | + ```bash |
| 60 | + cd ../../www |
| 61 | + pnpm dev |
| 62 | + ``` |
| 63 | + |
| 64 | +2. **Open Test Page:** |
| 65 | + - Navigate to: `http://localhost:3000/jitsi-test?local=true` |
| 66 | + - Fill form: |
| 67 | + - Room: `my-test-room` |
| 68 | + - Name: `Your Name` |
| 69 | + - Click "Join Meeting" |
| 70 | + |
| 71 | +3. **Verify Features:** |
| 72 | + - ✅ Meeting loads in iframe |
| 73 | + - ✅ Auto-recording starts (console: "🎬 Attempting to start recording...") |
| 74 | + - ✅ No "recording failed to start" errors |
| 75 | + - ✅ Recording indicator shows "Recording" in UI |
| 76 | + |
| 77 | +### Verify Recording Files |
| 78 | + |
| 79 | +**After leaving meeting:** |
| 80 | +```bash |
| 81 | +# Check recording files created |
| 82 | +ls -la recordings/ |
| 83 | + |
| 84 | +# View specific recording |
| 85 | +ls -la recordings/*/ |
| 86 | +``` |
| 87 | + |
| 88 | +**Files created:** |
| 89 | +- `{room-name}_{timestamp}.mp4` - Recording file |
| 90 | +- `metadata.json` - Recording metadata |
| 91 | + |
| 92 | +### Verify Events in Redis |
| 93 | + |
| 94 | +```bash |
| 95 | +# Check events for specific room |
| 96 | +redis-cli -p 6380 LRANGE "jitsi:events:my-test-room" 0 -1 |
| 97 | + |
| 98 | +# Monitor events in real-time |
| 99 | +redis-cli -p 6380 MONITOR |
| 100 | + |
| 101 | +# Subscribe to event publications |
| 102 | +redis-cli -p 6380 PSUBSCRIBE "jitsi:*" |
| 103 | +``` |
| 104 | + |
| 105 | +**Expected events:** |
| 106 | +- `api_ready` - Meeting API initialized |
| 107 | +- `videoConferenceJoined` - Participant joined |
| 108 | +- `recording_status_changed` - Recording started/stopped |
| 109 | +- `videoConferenceLeft` - Participant left |
| 110 | +- `ready_to_close` - Meeting ended |
| 111 | + |
| 112 | +## Architecture |
| 113 | + |
| 114 | +``` |
| 115 | +Frontend (localhost:3000) |
| 116 | + ↓ HTTPS iframe + Client events |
| 117 | +Nginx Proxy (jitsi.local:443) |
| 118 | + ↓ SSL termination |
| 119 | +Jitsi Web + Prosody + Jicofo + JVB |
| 120 | + ↓ Recording requests |
| 121 | +Jibri → MP4 files (/recordings/) |
| 122 | + ↓ Webhook events + Finalize script |
| 123 | +Event Collector (localhost:3002) |
| 124 | + ↓ Publish/Store |
| 125 | +Redis (localhost:6380) |
| 126 | +``` |
| 127 | + |
| 128 | +### Event Flow |
| 129 | + |
| 130 | +1. **Client Events** (from frontend): |
| 131 | + - `videoConferenceJoined` - User joins with participant info |
| 132 | + - `videoConferenceLeft` - User leaves meeting |
| 133 | + - `recording_status_changed` - Recording state changes |
| 134 | + |
| 135 | +2. **Jibri Events** (from recording service): |
| 136 | + - `recording_completed` - Recording finished with file metadata |
| 137 | + - `recording_available` - Recording file ready for processing |
| 138 | + - `recording_failed` - Recording error occurred |
| 139 | + |
| 140 | +3. **Event Correlation**: |
| 141 | + - Events linked by `roomName` and `sessionId` |
| 142 | + - Recording files contain session ID in path |
| 143 | + - Participant data from client events enriches recording metadata |
| 144 | + |
| 145 | +## Configuration |
| 146 | + |
| 147 | +### Key Environment Variables |
| 148 | + |
| 149 | +**Jibri (Recording Service):** |
| 150 | +- `JIBRI_WEBHOOK_SUBSCRIBERS` - Webhook endpoint for events (http://event-collector:3002/webhook/jibri) |
| 151 | +- `JIBRI_FINALIZE_RECORDING_SCRIPT_PATH` - Post-recording script (/scripts/finalize.sh) |
| 152 | +- `JIBRI_RECORDING_DIR` - Recording output directory (/recordings) |
| 153 | + |
| 154 | +**Event Collector:** |
| 155 | +- `REDIS_URL` - Redis connection (default: redis://localhost:6380) |
| 156 | +- `ENABLE_EVENT_LOGGING` - Enable detailed logging (true/false) |
| 157 | +- `REFLECTOR_WEBHOOK_URL` - Forward events to Reflector (optional) |
| 158 | + |
| 159 | +**Frontend:** |
| 160 | +- `NEXT_PUBLIC_JITSI_DOMAIN` - Jitsi domain (default: jitsi.local) |
| 161 | +- `NEXT_PUBLIC_EVENT_COLLECTOR_URL` - Event collector URL (default: localhost:3002) |
| 162 | +- `NEXT_PUBLIC_USE_LOCAL_JITSI` - Force local Jitsi (true/false) |
| 163 | + |
| 164 | +### Important Files |
| 165 | + |
| 166 | +- `docker-compose.simple.yml` - Self-contained Jitsi stack |
| 167 | +- `docker-compose.yml` - Production version (requires external network) |
| 168 | +- `nginx.conf` - SSL proxy configuration |
| 169 | +- `event-collector/` - TypeScript event aggregation service |
| 170 | +- `.gitignore` - Excludes recordings and certificates |
| 171 | + |
| 172 | +## Troubleshooting |
| 173 | + |
| 174 | +### Common Issues |
| 175 | + |
| 176 | +**Recording fails to start:** |
| 177 | +- Check Jibri container logs: `docker logs jitsi_jibri` |
| 178 | +- Verify DNS mapping in container: `docker exec jitsi_jibri cat /etc/hosts` |
| 179 | +- Should see: `192.168.x.x jitsi.local` |
| 180 | + |
| 181 | +**SSL certificate errors:** |
| 182 | +- Verify mkcert certificates exist: `ls -la ssl/` |
| 183 | +- Trust certificates: Run mkcert commands from setup section |
| 184 | + |
| 185 | +**Event collector not receiving events:** |
| 186 | +- Check event collector logs for incoming webhook calls |
| 187 | +- Verify frontend can reach localhost:3002 |
| 188 | +- Check Redis connection: `redis-cli -p 6380 ping` |
| 189 | + |
| 190 | +**iframe embedding blocked:** |
| 191 | +- Check nginx Content-Security-Policy headers |
| 192 | +- Verify frontend loads from localhost:3000 |
| 193 | + |
| 194 | +### Logs and Debugging |
| 195 | + |
| 196 | +```bash |
| 197 | +# Jitsi container logs |
| 198 | +docker logs jitsi_jibri # Recording service |
| 199 | +docker logs jitsi_prosody # XMPP server |
| 200 | +docker logs jitsi_nginx # SSL proxy |
| 201 | + |
| 202 | +# Event collector logs |
| 203 | +# See running event collector terminal |
| 204 | + |
| 205 | +# Redis operations |
| 206 | +redis-cli -p 6380 MONITOR |
| 207 | +``` |
| 208 | + |
| 209 | +### Clean Restart |
| 210 | + |
| 211 | +```bash |
| 212 | +# Stop all services |
| 213 | +docker compose -f docker-compose.simple.yml down |
| 214 | + |
| 215 | +# Remove volumes (clears config) |
| 216 | +docker compose -f docker-compose.simple.yml down -v |
| 217 | + |
| 218 | +# Clean start |
| 219 | +docker compose -f docker-compose.simple.yml up -d |
| 220 | +``` |
| 221 | + |
| 222 | +## Production Deployment |
| 223 | + |
| 224 | +For production use: |
| 225 | +1. Use `docker-compose.yml` (not simple version) |
| 226 | +2. Configure external `reflector` network |
| 227 | +3. Set proper environment variables in `.env` |
| 228 | +4. Use real SSL certificates (not mkcert) |
| 229 | +5. Configure `REFLECTOR_WEBHOOK_URL` for database integration |
| 230 | + |
| 231 | +## Security Notes |
| 232 | + |
| 233 | +- Local setup uses self-signed certificates (mkcert) |
| 234 | +- No authentication enabled (ENABLE_AUTH=0) |
| 235 | +- Recording files are stored locally in `./recordings/` |
| 236 | +- Event collector has no authentication |
| 237 | +- Redis has no password protection |
| 238 | + |
| 239 | +**For production, enable proper authentication and security measures.** |
0 commit comments