Skip to content
Get started
Get started
View Markdown

HTTP API: Real-time Events (SSE & WebSocket)

SSE & WebSocket Pub/Sub

Stream 86 job/queue events live over SSE or dispatch commands over WebSocket

SERVER-SENT EVENTS (SSE) GET /events EventSource Lightweight one-way push stream over standard HTTP. Global or per-queue (/events/queues/:q) auto-reconnect. Best for dashboards & live activity feeds WEBSOCKET (/ws) WS /ws Bidirectional 86 events + wildcards and JSON commands. Runs any TCP protocol command as JSON on one socket. Best for interactive consoles & live control
Zero polling: subscribe to GET /events for one-way browser feeds, or connect WS /ws for wildcard pub/sub plus JSON command execution.

4 real-time channels on port 6790: SSE for one-way streaming and WebSocket for selective pub/sub plus JSON command dispatch.

ProtocolPathScope
SSEGET /eventsAll typed events + periodic snapshots
SSEGET /events/queues/:queueJob events for :queue + periodic/dashboard events
WebSocketws://host:6790/wsSelective pub/sub (86 explicit events + wildcards) and JSON commands
WebSocketws://host:6790/ws/queues/:queuejob:* scoped to :queue + non-job pub/sub + JSON commands

SSE emits named events matching WebSocket pub/sub names (job:completed, queue:counts, stats:snapshot, etc.). Job events include id: (Last-Event-ID resume) and JSON data: { queue, jobId, timestamp, error?, progress?, prev?, delay? }.

  • First frame is unnamed: { "connected": true, "clientId": "..." }.
  • :heartbeat comments stream every 30s; snapshots stream automatically (stats:snapshot 5s, health:status 10s, storage:status 30s).
  • Attach listeners with addEventListener (onmessage receives only the initial unnamed frame).
  • For Authorization: Bearer <token>, use @microsoft/fetch-event-source (native EventSource cannot send custom headers).
const events = new EventSource('http://localhost:6790/events');
for (const name of ['job:completed', 'job:failed', 'queue:counts']) {
events.addEventListener(name, (e) => console.log(`[${e.type}]`, JSON.parse(e.data)));
}

Pub/sub envelope: { "event": "job:completed", "ts": 1710000000000, "data": { "queue": "payments", "jobId": "abc-123" } }.

Send Subscribe after connecting for selective delivery, or Unsubscribe (events: [] clears all):

{ "cmd": "Subscribe", "events": ["job:*", "queue:counts", "stats:snapshot"], "reqId": "1" }
// -> { "ok": true, "subscribed": ["job:*", "queue:counts", "stats:snapshot"], "reqId": "1" }
{ "cmd": "Unsubscribe", "events": ["job:progress"] }
{ "cmd": "Unsubscribe", "events": [] }

Legacy mode: Sockets that never send Subscribe receive all job events in flat { eventType: "completed", queue, jobId, ... } format.

Send any TCP protocol command as JSON on the same socket:

ws.send(JSON.stringify({ cmd: 'Pause', queue: 'emails', reqId: '2' }));
// -> { "ok": true, "reqId": "2" }
  • Auth: With AUTH_TOKENS set, send Authorization: Bearer <token> on the HTTP upgrade request (401 before open; post-connect { "cmd": "Auth" } does not replace handshake auth). Native browser WebSocket cannot set custom headers.
  • Disconnect cleanup: Closing a socket releases eligible active deliveries owned by that client without charging an attempt. Renewed leases stay active until expiry/stall recovery; detached pulls are unaffected. Eligible cron: prevent-overlap deliveries are discarded on memory/SQLite (and on PostgreSQL unless dependency-protected, which uses ordinary transactional release).
const ws = new WebSocket('ws://localhost:6790/ws');
ws.onopen = () => ws.send(JSON.stringify({
cmd: 'Subscribe',
events: ['job:*', 'queue:counts', 'stats:snapshot', 'health:status', 'worker:*', 'dlq:*', 'cron:*', 'queue:paused', 'queue:resumed'],
}));
ws.onmessage = (e) => {
const msg = JSON.parse(e.data);
if (msg.event === 'queue:counts') updateQueueRow(msg.data.queue, msg.data);
else if (msg.event === 'stats:snapshot') updateOverviewCards(msg.data);
else if (msg.event === 'dlq:added') showAlert(msg.data.jobId, msg.data.reason);
else if (msg.reqId) handleCommandResponse(msg);
};
PatternMatches
*Every emitted event
job:*All 21 explicit job events (plus legacy job:waiting and job:duplicated bridge emissions; use job:deduplicated for exact deduplication subscription)
queue:*All 10 queue events (including coalesced queue:counts)
flow:*, config:*, batch:*, client:*, cleanup:*Both events in each namespace
worker:*All 7 worker events
dlq:*, cron:*, webhook:*All 6 events in each namespace
storage:*All 5 storage events
ratelimit:*, server:*All 4 events in each namespace
concurrency:*All 3 concurrency events
stats:*, health:*, auth:*, memory:*Single event in each namespace

Complete Explicit Event Catalog (86 Events)

Section titled “Complete Explicit Event Catalog (86 Events)”

Payload fields marked with ? are included when available on that code path.

EventPayloadTrigger
job:pushedqueue, jobIdJob enqueued
job:activequeue, jobIdWorker claimed job
job:completedqueue, jobIdJob acknowledged
job:failedqueue, jobId, errorJob failed
job:removedqueue, jobId, prev?Job cancelled or deleted
job:promotedjobIdDelayed job promoted to waiting
job:progressqueue, jobId, progressProgress updated (0-100)
job:delayedqueue, jobId, delayJob delayed or scheduled for retry
job:stalledqueue, jobId, stallCount?, action?Stall detected
job:retriedqueue, jobId, prev?Failed job retried
job:discardedjobIdJob discarded to DLQ
job:priority-changedjobId, newPriorityPriority changed
job:data-updatedjobIdPayload updated
job:delay-changedjobId, newDelayDelay updated
job:timeoutqueue, jobId, timeoutProcessing timeout exceeded
job:lock-expiredqueue, jobId, renewalCountOwnership lock expired
job:deduplicatedqueue, jobId, strategyPush matched an existing dedup key
job:waiting-childrenqueue, jobId, dependsOn?Job waiting on dependencies
job:dependencies-resolvedqueue, jobIdAll dependencies completed
job:moved-to-delayedjobId, delayActive job explicitly delayed
job:expiredqueue, jobId, ttl, ageJob TTL expired
EventPayloadTrigger
queue:countsqueue, waiting, prioritized, active, completed, failed, delayedCoalesced (10ms window) count update after lifecycle activity; replaces per-queue polling
queue:pausedqueueQueue paused
queue:resumedqueueQueue resumed
queue:drainedqueue, countQueued jobs drained
queue:cleanedqueue, state, countOld jobs cleaned
queue:obliteratedqueueQueue destroyed
queue:createdqueueFirst job pushed to a new queue
queue:removedqueueQueue removed
queue:idlequeue, idleSecondsQueue empty for QUEUE_IDLE_THRESHOLD_MS (default 30000)
queue:thresholdqueue, size, thresholdSize exceeded QUEUE_SIZE_THRESHOLD (default 0 = off)
flow:completedparentJobId, queue, childrenCountAll flow children completed
flow:failedparentJobId, failedChildId, queue, errorFlow child failed terminally
EventPayloadTrigger
dlq:addedqueue, jobId, reasonEntry moved to DLQ
dlq:retriedqueue, jobId, countSingle DLQ entry retried
dlq:retry-allqueue, countAll DLQ entries retried
dlq:purgedqueue, countDLQ purged
dlq:auto-retriedqueue, countBackground auto-retry ran
dlq:expiredqueue, countExpired DLQ entries pruned
cron:createdname, queue, pattern?, every?, nextRunCron added
cron:updatedname, queue, pattern?, every?, nextRunCron updated
cron:deletednameCron removed
cron:firedname, queueCron pushed a job
cron:missedname, queue, errorCron missed execution window
cron:skippedname, queue, reasonTick skipped due to overlap or missing worker
EventPayloadTrigger
worker:connectedworkerId, name, queues, hostname?, pid?Worker registered
worker:disconnectedworkerId, name?, clientId?Worker unregistered or disconnected
worker:heartbeatworkerIdWorker heartbeat received
worker:idleworkerId, processedJobsWorker reached zero active jobs
worker:removed-staleworkerId, nameStale worker pruned
worker:overloadedworkerId, name, activeJobs, concurrency, overloadedSecondsAt max concurrency for WORKER_OVERLOAD_THRESHOLD_MS (30000)
worker:errorworkerId, name, failedJobs, processedJobs, failureRateFailure milestones (5, 10, 25, 50, 100)
ratelimit:setqueue, max, duration?, ttl?Queue rate limit set
ratelimit:clearedqueueQueue rate limit cleared
ratelimit:hitclientIdClient exceeded protocol/HTTP rate limit
ratelimit:rejectedqueuePull rejected by queue token bucket
concurrency:setqueue, concurrencyQueue concurrency limit set
concurrency:clearedqueueQueue concurrency limit cleared
concurrency:rejectedqueuePull rejected because concurrency slots were full
webhook:addedid, url, eventsWebhook created
webhook:removedidWebhook deleted
webhook:firedwebhookId, url, eventDelivery succeeded
webhook:failedwebhookId, url, event, errorDelivery failed
webhook:enabledwebhookIdWebhook enabled
webhook:disabledwebhookIdWebhook disabled

Batch, Client, Config, Storage, Server & Periodic (21)

Section titled “Batch, Client, Config, Storage, Server & Periodic (21)”
EventPayloadTrigger
batch:pushedqueue, total, inserted, duplicatesBulk push inserted >= 1 job
batch:pulledqueue, countBatch pull delivered > 1 job
client:connectedclientId, transportTCP client connected
client:disconnectedclientId, transportTCP client disconnected
auth:failedclientId? or transportTCP or HTTP auth failed
cleanup:orphans-removedcountSilent active jobs recovered as stalls
cleanup:stale-deps-removedcountStale dependency links pruned
config:stall-changedqueue, configStall config updated
config:dlq-changedqueue, configDLQ config updated
stats:snapshotwaiting, active, delayed, completed, dlq, totalPushed, totalCompleted, totalFailed, pushPerSec, pullPerSec, uptime, queues, workers, cronJobsPeriodic snapshot every 5s
health:statusok, uptime, memory: { rss, heapUsed }, connectionsPeriodic snapshot every 10s
storage:statuscollections, diskFullPeriodic snapshot every 30s
storage:backup-startedbucketS3 backup started
storage:backup-completedbucket, keyS3 backup finished
storage:backup-failedbucket, errorS3 backup failed
storage:size-warningsizeMB, thresholdMBSQLite DB exceeded STORAGE_WARNING_MB
server:startedtcpPort, httpPort, shardsServer listeners ready
server:shutdownsignalGraceful shutdown initiated
server:recoveredqueues, jobsPersistent state recovered on startup
server:memory-warningheapUsedMB, thresholdMB, rssMBHeap exceeded MEMORY_WARNING_MB
memory:compacted{}Manual memory compaction finished