WebSocket-based pub/sub for presence, live typing indicators, and any event you want to push to connected clients in real time — backed by Redis and running entirely on your server.
Requires Redis. nSelf includes Redis as an optional service — enable it in your config before installing nself-realtime.
# Ensure Redis is enabled in your nself config first
nself license set nself_pro_...
nself plugin install realtime
nself build
nself startnself-realtime provides a WebSocket server backed by Redis pub/sub. Clients connect via WebSocket and subscribe to named channels (topics). When any service publishes an event to a topic — whether from nself-chat, nself-bots, or your own custom service — all subscribed clients receive it instantly.
Presence tracking maintains an online/away/offline state per user, updated automatically on WebSocket connect and disconnect with a configurable heartbeat. nself-chat uses this to show who is online in each channel and to display typing indicators.
Client connections are authenticated using short-lived connection tokens issued by your Hasura JWT. Tokens are scoped to a user identity so the server can enforce topic-level access rules — a user in channel A cannot subscribe to channel B's events without the right role.
| Variable | Required | Description |
|---|---|---|
REALTIME_REDIS_URL | Yes | Redis connection URL, e.g. redis://localhost:6379 |
REALTIME_CORS_ORIGIN | Yes | Allowed WebSocket origin, e.g. https://chat.yourdomain.com |
DATABASE_URL | Yes | Postgres connection string for presence persistence |
REALTIME_HEARTBEAT_SECONDS | No | Interval clients must ping to stay present. Default: 30 |
REALTIME_MAX_CONNECTIONS | No | Maximum concurrent WebSocket connections. Default: 10000 |
| Endpoint | Method | Description |
|---|---|---|
/realtime/connect | WebSocket | Client WebSocket connection endpoint |
/realtime/publish | POST | Server-side publish to a topic (for internal services) |
/realtime/presence/:topic | GET | Get current presence state for a topic |
/realtime/token | POST | Issue a connection token for an authenticated user |
/health | GET | Plugin health and Redis connectivity |
| Table | Purpose |
|---|---|
np_realtime_presence | Last-seen timestamp and status per user (synced from Redis on disconnect) |
| Event | Payload |
|---|---|
realtime.client.connected | User ID, connection ID, topic list |
realtime.client.disconnected | User ID, session duration |
realtime.presence.changed | User ID, old status, new status, topic |
nself-realtime is the delivery layer for the entire ɳChat bundle. nself-chat publishes chat.message.created events to topics named after channel IDs. Clients subscribed to a channel topic receive messages instantly over WebSocket without polling. Typing indicators are ephemeral events that bypass Postgres entirely and live only in Redis.
| Feature | nself-realtime | Pusher | Ably |
|---|---|---|---|
| Data in transit | Your server only | Pusher cloud | Ably cloud |
| Cost (100K messages/day) | $0.99/mo (bundle) | ~$49/mo | ~$35/mo |
| Connection limit | Your RAM / Redis | Plan-dependent | Plan-dependent |
WebSocket connections dropping: Check REALTIME_HEARTBEAT_SECONDS vs your reverse proxy idle timeout. Nginx default is 60s — set it higher or match heartbeat to keep connections alive.
Redis connection refused: Confirm Redis is running — nself status shows all service states. The optional Redis service must be enabled in your nself config before install.
Port: 3109 | Bundle: ɳChat ($0.99/mo) or ɳSelf+ ($3.99/mo) | Last Updated: May 2026 | Plugin Version 1.0.13