brightery / websocket-gateway
Native WebSocket gateway for Brightery Framework realtime events.
Package info
github.com/Brightery/brightery-websocket-gateway
pkg:composer/brightery/websocket-gateway
v1.0.0
2026-08-05 18:41 UTC
Requires
- php: ^8.4
- brightery/framework: ^1.0
Suggests
- ext-redis: Required for horizontally scalable Redis Streams event delivery.
README
A small native PHP RFC 6455 gateway for Brightery Framework realtime events.
Install
composer require brightery/websocket-gateway "^1.0"
Run with Redis Streams
GATEWAY_LISTEN=0.0.0.0:8090 \
GATEWAY_EVENT_DRIVER=redis_stream \
GATEWAY_REDIS_STREAM=brightery:realtime:events \
GATEWAY_REDIS_GROUP=brightery-gateway-node-a \
GATEWAY_REDIS_CONSUMER=worker-1 \
GATEWAY_NODE_ID=node-a \
REDIS_HOST=127.0.0.1 \
REDIS_PORT=6379 \
GATEWAY_AUTH_SECRET='<strong shared secret>' \
vendor/bin/brightery-gateway
Public channels can be subscribed to directly. Private, tenant, and presence channels require unexpired HMAC signatures bound to socket ID, channel, user, tenant, and expiry.
Security boundaries
- private and presence channels fail closed without
GATEWAY_AUTH_SECRET; - client frames must be masked, bounded, unfragmented, and valid UTF-8;
- control frames are limited to 125 bytes;
- Redis and file event inputs reject malformed or oversized payloads;
- TLS should terminate at a trusted reverse proxy;
- Redis must use private networking and authentication;
- multi-node presence should use the Redis presence store.
Run the package test suite and live network/load tests for the intended topology before production deployment.