sockudo 2.9.2

A simple, fast, and secure WebSocket server for real-time applications.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
# =============================================================================
# Sockudo Environment Configuration Template
# 
# Copy this file to .env and customize for your environment:
# cp .env.example .env
# =============================================================================

# -----------------------------------------------------------------------------
# Environment Settings
# -----------------------------------------------------------------------------
# Set to 'development', 'staging', or 'production'
ENVIRONMENT=development

# Debug mode (true/false)
DEBUG_MODE=false

# Log level (error, warn, info, debug, trace)
LOG_LEVEL=info

# Host and port configuration
HOST=0.0.0.0
PORT=6001
METRICS_PORT=9601

# -----------------------------------------------------------------------------
# Security Settings
# -----------------------------------------------------------------------------
# Redis password (REQUIRED for production)
REDIS_PASSWORD=

# MySQL passwords (if using MySQL)
MYSQL_ROOT_PASSWORD=
MYSQL_PASSWORD=

# Grafana admin password (if using monitoring)
GRAFANA_PASSWORD=admin123

# JWT secret for authentication (generate with: openssl rand -base64 32)
JWT_SECRET=

# -----------------------------------------------------------------------------
# Application Configuration
# -----------------------------------------------------------------------------
# Default application settings (for development/testing)
SOCKUDO_DEFAULT_APP_ID=demo-app
SOCKUDO_DEFAULT_APP_KEY=demo-key
SOCKUDO_DEFAULT_APP_SECRET=demo-secret
SOCKUDO_DEFAULT_APP_ENABLED=true

# Feature flags
SOCKUDO_ENABLE_CLIENT_MESSAGES=true
SOCKUDO_DEFAULT_APP_ENABLE_USER_AUTHENTICATION=false
SOCKUDO_DEFAULT_APP_ENABLE_WATCHLIST_EVENTS=false

# Origin validation (comma-separated list, supports wildcards)
# Examples: https://app.example.com,*.staging.example.com,http://localhost:3000
# Leave empty to allow all origins (default)
# SOCKUDO_DEFAULT_APP_ALLOWED_ORIGINS=

# Connection limits
SOCKUDO_DEFAULT_APP_MAX_CONNECTIONS=1000
SOCKUDO_DEFAULT_APP_MAX_CLIENT_EVENTS_PER_SECOND=100
SOCKUDO_DEFAULT_APP_MAX_READ_REQUESTS_PER_SECOND=100
SOCKUDO_DEFAULT_APP_MAX_BACKEND_EVENTS_PER_SECOND=100

# Channel and event limits
SOCKUDO_DEFAULT_APP_MAX_PRESENCE_MEMBERS_PER_CHANNEL=100
SOCKUDO_DEFAULT_APP_MAX_PRESENCE_MEMBER_SIZE_IN_KB=2
SOCKUDO_DEFAULT_APP_MAX_CHANNEL_NAME_LENGTH=200
SOCKUDO_DEFAULT_APP_MAX_EVENT_CHANNELS_AT_ONCE=100
SOCKUDO_DEFAULT_APP_MAX_EVENT_NAME_LENGTH=200
SOCKUDO_DEFAULT_APP_MAX_EVENT_PAYLOAD_IN_KB=100
SOCKUDO_DEFAULT_APP_MAX_EVENT_BATCH_SIZE=10

# -----------------------------------------------------------------------------
# Driver Configuration
# -----------------------------------------------------------------------------
# Adapter driver: local, redis, redis-cluster, nats
ADAPTER_DRIVER=redis

# Cache driver: memory, redis, redis-cluster, none
CACHE_DRIVER=redis

# Queue driver: memory, redis, redis-cluster, sqs, none
QUEUE_DRIVER=redis

# App manager driver: memory, mysql, dynamodb, pgsql
APP_MANAGER_DRIVER=memory

# Metrics driver: prometheus
METRICS_DRIVER=prometheus

# Rate limiter backend driver: memory, redis, redis-cluster
RATE_LIMITER_DRIVER=redis

# -----------------------------------------------------------------------------
# Database Configuration
# -----------------------------------------------------------------------------
# Redis Configuration
DATABASE_REDIS_HOST=localhost
DATABASE_REDIS_PORT=6379
DATABASE_REDIS_PASSWORD=${REDIS_PASSWORD}
DATABASE_REDIS_DB=0
DATABASE_REDIS_KEY_PREFIX=sockudo:

# Redis URL override (if you want to use a connection string instead)
# REDIS_URL=redis://username:password@host:port/db

# MySQL Configuration (if using MySQL for app management)
DATABASE_MYSQL_HOST=mysql
DATABASE_MYSQL_PORT=3306
DATABASE_MYSQL_USERNAME=sockudo
DATABASE_MYSQL_PASSWORD=${MYSQL_PASSWORD}
DATABASE_MYSQL_DATABASE=sockudo
DATABASE_MYSQL_TABLE_NAME=applications
# DATABASE_MYSQL_POOL_MIN=2
# DATABASE_MYSQL_POOL_MAX=10

# PostgreSQL Configuration (if using PostgreSQL)
# DATABASE_POSTGRES_HOST=postgres
# DATABASE_POSTGRES_PORT=5432
# DATABASE_POSTGRES_USERNAME=sockudo
# DATABASE_POSTGRES_PASSWORD=sockudo123
# DATABASE_POSTGRES_DATABASE=sockudo
# DATABASE_POSTGRES_POOL_MIN=2
# DATABASE_POSTGRES_POOL_MAX=10

# DynamoDB Configuration (if using AWS DynamoDB)
# DATABASE_DYNAMODB_REGION=us-east-1
# DATABASE_DYNAMODB_TABLE_NAME=sockudo-applications
# DATABASE_DYNAMODB_ENDPOINT_URL=http://localstack:4566  # For local testing
# AWS_ACCESS_KEY_ID=your-access-key
# AWS_SECRET_ACCESS_KEY=your-secret-key

# -----------------------------------------------------------------------------
# Redis Cluster Configuration (if using Redis Cluster)
# -----------------------------------------------------------------------------
# Comma-separated list of cluster nodes
# REDIS_CLUSTER_NODES=redis-cluster-1:7000,redis-cluster-2:7001,redis-cluster-3:7002

# Redis Cluster Queue Configuration
# REDIS_CLUSTER_QUEUE_CONCURRENCY=5
# REDIS_CLUSTER_QUEUE_PREFIX=sockudo_queue:

# -----------------------------------------------------------------------------
# SSL/TLS Configuration
# -----------------------------------------------------------------------------
# Enable SSL (true/false)
SSL_ENABLED=false

# SSL certificate paths (use Let's Encrypt in production)
SSL_CERT_PATH=/app/ssl/cert.pem
SSL_KEY_PATH=/app/ssl/key.pem

# Redirect HTTP to HTTPS
SSL_REDIRECT_HTTP=false

# HTTP port for redirects
SSL_HTTP_PORT=80

# Domain name (for Let's Encrypt)
DOMAIN=localhost

# -----------------------------------------------------------------------------
# Unix Socket Configuration (Alternative to HTTP/HTTPS)
# -----------------------------------------------------------------------------
# Enable Unix socket server (disables HTTP/HTTPS when enabled)
UNIX_SOCKET_ENABLED=false

# Unix socket file path
UNIX_SOCKET_PATH=/var/run/sockudo/sockudo.sock

# Socket file permissions in octal (e.g., "755", "660", "644")
# Default: 660 (rw-rw----, most restrictive reasonable default)
UNIX_SOCKET_PERMISSION_MODE=660

# -----------------------------------------------------------------------------
# Monitoring Configuration
# -----------------------------------------------------------------------------
# Enable metrics collection
METRICS_ENABLED=true

# Metrics host and port
METRICS_HOST=0.0.0.0

# Prometheus metrics prefix
METRICS_PROMETHEUS_PREFIX=sockudo_

# Enable monitoring stack (Prometheus + Grafana)
MONITORING_ENABLED=false

# Prometheus data retention
PROMETHEUS_RETENTION=30d

# -----------------------------------------------------------------------------
# Rate Limiting Configuration
# -----------------------------------------------------------------------------
# Enable rate limiting
RATE_LIMITER_ENABLED=true

# API rate limiting
RATE_LIMITER_API_MAX_REQUESTS=100
RATE_LIMITER_API_WINDOW_SECONDS=60
RATE_LIMITER_API_TRUST_HOPS=0

# WebSocket rate limiting
RATE_LIMITER_WS_MAX_REQUESTS=20
RATE_LIMITER_WS_WINDOW_SECONDS=60

# -----------------------------------------------------------------------------
# Queue Configuration
# -----------------------------------------------------------------------------
# Queue concurrency
QUEUE_REDIS_CONCURRENCY=5
QUEUE_REDIS_PREFIX=sockudo_queue:

# SQS Configuration (if using AWS SQS)
# QUEUE_SQS_REGION=us-east-1
# QUEUE_SQS_VISIBILITY_TIMEOUT=30
# QUEUE_SQS_MAX_MESSAGES=10
# QUEUE_SQS_WAIT_TIME_SECONDS=5
# QUEUE_SQS_CONCURRENCY=5
# QUEUE_SQS_FIFO=false
# QUEUE_SQS_ENDPOINT_URL=http://localstack:4566  # For local testing

# -----------------------------------------------------------------------------
# Webhook Configuration
# -----------------------------------------------------------------------------
# Enable webhook batching
WEBHOOK_BATCHING_ENABLED=true
WEBHOOK_BATCHING_DURATION=50

# -----------------------------------------------------------------------------
# NATS Configuration (if using NATS adapter)
# -----------------------------------------------------------------------------
# NATS servers (comma-separated)
# NATS_SERVERS=nats://nats:4222

# NATS authentication
# NATS_USERNAME=
# NATS_PASSWORD=
# NATS_TOKEN=

# NATS connection settings
# NATS_CONNECTION_TIMEOUT_MS=5000
# NATS_REQUEST_TIMEOUT_MS=5000

# -----------------------------------------------------------------------------
# Instance Configuration
# -----------------------------------------------------------------------------
# Unique process identifier
INSTANCE_PROCESS_ID=sockudo-docker-1

# Graceful shutdown timeout (seconds)
SHUTDOWN_GRACE_PERIOD=10

# User authentication timeout (seconds)
USER_AUTHENTICATION_TIMEOUT=3600

# WebSocket payload limit (KB)
WEBSOCKET_MAX_PAYLOAD_KB=64

# -----------------------------------------------------------------------------
# Cluster Configuration (for multi-node deployments)
# -----------------------------------------------------------------------------
# Cluster hostname
CLUSTER_HOSTNAME=localhost

# Cluster communication port
CLUSTER_PORT=6002

# Cluster intervals (milliseconds)
CLUSTER_HELLO_INTERVAL=5000
CLUSTER_CHECK_INTERVAL=10000
CLUSTER_NODE_TIMEOUT=30000
CLUSTER_MASTER_TIMEOUT=60000

# -----------------------------------------------------------------------------
# Resource Limits (for Docker deployment)
# -----------------------------------------------------------------------------
# Sockudo container limits
SOCKUDO_MEMORY_LIMIT=512M
SOCKUDO_CPU_LIMIT=1.0
SOCKUDO_MEMORY_RESERVATION=256M
SOCKUDO_CPU_RESERVATION=0.5

# Redis container limits
REDIS_MEMORY_LIMIT=256M
REDIS_CPU_LIMIT=0.5

# MySQL container limits (if using MySQL)
MYSQL_MEMORY_LIMIT=512M
MYSQL_CPU_LIMIT=1.0

# -----------------------------------------------------------------------------
# Scaling Configuration
# -----------------------------------------------------------------------------
# Number of Sockudo replicas
SOCKUDO_REPLICAS=1

# Load balancer configuration
LOAD_BALANCER_ENABLED=false

# -----------------------------------------------------------------------------
# Development Settings
# -----------------------------------------------------------------------------
# Enable development tools (Redis Commander, PHPMyAdmin, etc.)
DEV_TOOLS_ENABLED=true

# Development ports
REDIS_COMMANDER_PORT=8081
PHPMYADMIN_PORT=8080
MAILHOG_SMTP_PORT=1025
MAILHOG_WEB_PORT=8025

# -----------------------------------------------------------------------------
# Backup Configuration
# -----------------------------------------------------------------------------
# Backup retention (days)
BACKUP_RETENTION_DAYS=30

# Backup schedule (cron format)
BACKUP_SCHEDULE="0 2 * * *"  # Daily at 2 AM

# -----------------------------------------------------------------------------
# External Services (optional)
# -----------------------------------------------------------------------------
# External Redis URL (if not using Docker Redis)
# EXTERNAL_REDIS_URL=redis://your-redis-host:6379

# External MySQL URL (if not using Docker MySQL)
# EXTERNAL_MYSQL_URL=mysql://user:pass@host:3306/db

# Webhook endpoints for testing
# TEST_WEBHOOK_URL=https://webhook.site/your-unique-id

# -----------------------------------------------------------------------------
# AWS Configuration (if using AWS services)
# -----------------------------------------------------------------------------
# AWS Region
# AWS_REGION=us-east-1

# AWS Credentials (use IAM roles in production)
# AWS_ACCESS_KEY_ID=
# AWS_SECRET_ACCESS_KEY=

# AWS Profile
# AWS_PROFILE=default

# -----------------------------------------------------------------------------
# CORS Configuration
# -----------------------------------------------------------------------------
# Allowed origins (comma-separated, use * for all)
CORS_ORIGINS=*

# Allowed methods
CORS_METHODS=GET,POST,OPTIONS

# Allowed headers
CORS_HEADERS=Authorization,Content-Type,X-Requested-With,Accept

# Allow credentials
CORS_CREDENTIALS=true

# -----------------------------------------------------------------------------
# Health Check Configuration
# -----------------------------------------------------------------------------
# Health check intervals (seconds)
HEALTH_CHECK_INTERVAL=30
HEALTH_CHECK_TIMEOUT=10
HEALTH_CHECK_RETRIES=3
HEALTH_CHECK_START_PERIOD=30

# -----------------------------------------------------------------------------
# Logging Configuration
# -----------------------------------------------------------------------------
# Log file rotation
LOG_MAX_SIZE=10m
LOG_MAX_FILES=3

# Structured logging format (json/text)
LOG_FORMAT=text

# Log file path (if logging to file)
LOG_FILE_PATH=/app/logs/sockudo.log

# -----------------------------------------------------------------------------
# Performance Tuning
# -----------------------------------------------------------------------------
# Connection pool sizes
DATABASE_CONNECTION_POOL_SIZE=10
DATABASE_POOLING_ENABLED=true
DATABASE_POOL_MIN=2
DATABASE_POOL_MAX=10
REDIS_CONNECTION_POOL_SIZE=10

# Cache settings
CACHE_TTL_SECONDS=300
CACHE_CLEANUP_INTERVAL=60
CACHE_MAX_CAPACITY=10000

# -----------------------------------------------------------------------------
# Testing Configuration
# -----------------------------------------------------------------------------
# Test database configuration (using non-standard port 13306)
TEST_DATABASE_URL=mysql://sockudo:test123@localhost:13306/sockudo_test

# Test Redis configuration (using non-standard port 16379)
TEST_REDIS_URL=redis://localhost:16379/1

# Enable test mode
TEST_MODE=false