esgn
06/30/2025, 9:00 PMMarvin
06/30/2025, 9:00 PMMarvin
06/30/2025, 9:02 PMPREFECT_WORKER_HEARTBEAT_SECONDS
- Controls how often the worker sends heartbeat signals
- PREFECT_API_KEEPALIVE
- Controls the keepalive behavior of the connection
The single WebSocket connection is managed by Prefect's events client, which handles:
- Connection establishment
- Event sending and receiving
- Automatic reconnection
- Event buffering when disconnected
This design is more efficient than maintaining separate WebSocket connections for different types of events, as it reduces overhead and simplifies connection management.esgn
06/30/2025, 9:04 PMMarvin
06/30/2025, 9:30 PMMarvin
06/30/2025, 9:33 PMdeploy()
, a single WebSocket connection is established between your local Python process and the Prefect server. This connection is used for:
1. Sending flow run status updates
2. Sending logs
3. Receiving any server-side updates
The connection is handled by Prefect's events client, which manages bidirectional communication over a single WebSocket channel. This is true whether you're running the flow locally or using a worker - the difference is just in which process maintains that connection.
You can see this connection being established in debug logs with messages like:
DEBUG | prefect events clients - Opening websocket connection
DEBUG | prefect events clients - Pinging to ensure websocket connected
DEBUG | prefect events clients - Pong received Websocket connected
So to directly answer your question: it's just one WebSocket connection, not separate ones for events in and out.