Skip to main content

Overview

AWX uses WebSockets to provide real-time updates as jobs execute, enabling live playbook output and status updates in the UI. Based on docs/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 begins
  • playbook_on_play_start - Play starts
  • playbook_on_task_start - Task starts
  • playbook_on_stats - Final statistics
  • playbook_on_notify - Handler notification

Runner Events

  • runner_on_start - Task begins on host
  • runner_on_ok - Task succeeded
  • runner_on_failed - Task failed
  • runner_on_skipped - Task skipped
  • runner_on_unreachable - Host unreachable
  • runner_on_async_poll - Async task polling
  • runner_on_async_ok - Async task completed
  • runner_on_async_failed - Async task failed
  • runner_retry - Task retry

Item Events

  • runner_item_on_ok - Loop item succeeded
  • runner_item_on_failed - Loop item failed
  • runner_item_on_skipped - Loop item skipped

Live Job Monitoring

Architecture

AWX uses django-channels with Redis for WebSocket support:
  1. Task Pods - Generate events during job execution
  2. wsrelay - Relays events from task pods to web pods
  3. Web Pods - Serve WebSocket connections to clients
  4. 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

Only subscribe to events you need. Subscribing to all job events can be overwhelming.
WebSocket connections can drop. Implement automatic reconnection with exponential backoff.
Update subscriptions as needed when navigating between jobs/workflows.
Close WebSocket connections when no longer needed to conserve resources.

Complete Example