Overview
AWX uses WebSockets to provide real-time updates as jobs execute, enabling live playbook output and status updates in the UI. Based ondocs/websockets.md from the AWX source.
WebSocket Endpoint
WebSocket connections require authentication via a valid token in the URL.
Connection
Establish Connection
Python Example
Subscriptions
After connecting, subscribe to event groups by sending a JSON message:Event Groups
array
Subscribe to job status changes:
"status_changed"- Job status updates"summary"- Job summaries
array
Subscribe to events for specific job IDs
array
Subscribe to workflow job events by ID
array
Subscribe to project update events by ID
array
Subscribe to inventory update events by ID
array
Subscribe to ad hoc command events by ID
array
Subscribe to system job events by ID
array
Subscribe to schedule changes:
"changed"- Schedule modifications
array
Control channel messages:
"limit_reached_<user_id>"- Rate limit notifications
Sending a new subscription message replaces all previous subscriptions.
Event Messages
Job Status Changed
Job Event
Workflow Event
Event Types
Playbook Events
playbook_on_start- Playbook execution beginsplaybook_on_play_start- Play startsplaybook_on_task_start- Task startsplaybook_on_stats- Final statisticsplaybook_on_notify- Handler notification
Runner Events
runner_on_start- Task begins on hostrunner_on_ok- Task succeededrunner_on_failed- Task failedrunner_on_skipped- Task skippedrunner_on_unreachable- Host unreachablerunner_on_async_poll- Async task pollingrunner_on_async_ok- Async task completedrunner_on_async_failed- Async task failedrunner_retry- Task retry
Item Events
runner_item_on_ok- Loop item succeededrunner_item_on_failed- Loop item failedrunner_item_on_skipped- Loop item skipped
Live Job Monitoring
Architecture
AWX uses django-channels with Redis for WebSocket support:- Task Pods - Generate events during job execution
- wsrelay - Relays events from task pods to web pods
- Web Pods - Serve WebSocket connections to clients
- Redis - Pub/sub backend for event distribution
Event Flow
Heartbeat System
Web pods send heartbeats via pg_notify so task pods know which web pods are active and need event relays.Security
The relay endpoint used by wsrelay is protected by a shared secret to prevent unauthorized access. Only wsrelay can connect to the relay endpoint.Best Practices
Subscribe Selectively
Subscribe Selectively
Only subscribe to events you need. Subscribing to all job events can be overwhelming.
Handle Reconnection
Handle Reconnection
WebSocket connections can drop. Implement automatic reconnection with exponential backoff.
Manage Subscriptions
Manage Subscriptions
Update subscriptions as needed when navigating between jobs/workflows.
Close Connections
Close Connections
Close WebSocket connections when no longer needed to conserve resources.