Skip to content
Latchkey

What Is a WebSocket? Persistent Two-Way Connections

A WebSocket is a long-lived connection that stays open after an HTTP handshake, letting client and server send messages to each other at any time.

Plain HTTP is request-response: the client asks and the server answers. WebSockets break that pattern by upgrading a connection so both sides can push messages whenever they want. Live build logs, deploy progress streams, and dashboards that update without refreshing often use WebSockets.

The upgrade handshake

A WebSocket starts as an HTTP request with an Upgrade header. If the server agrees, the connection switches protocols and stays open as a bidirectional channel rather than closing after one response.

Full-duplex messaging

Once open, either side can send messages independently, with no need to poll. This is ideal for real-time data where the server has updates to push.

Where it appears in CI/CD

  • Live streaming of build and deploy logs to a UI.
  • Real-time job status on a dashboard.
  • Interactive consoles attached to a running container.

Connections drop

Long-lived connections are inherently fragile: a proxy timeout, a network blip, or an idle period can sever them. Robust clients reconnect automatically and resume where they left off.

Proxies and load balancers

Not every proxy or load balancer forwards WebSocket upgrades by default. A deploy that puts a new proxy in front of a service can silently break WebSocket traffic even though ordinary HTTP still works.

Transient drops in pipelines

A dropped log stream during a long deploy is a transient blip, not a build failure. On Latchkey, runner-side streaming reconnects through brief network interruptions so a momentary drop does not cut off your logs or fail the job.

Key takeaways

  • A WebSocket upgrades an HTTP connection into a persistent two-way channel.
  • It powers real-time features like live log streaming and status dashboards.
  • Connections drop on blips and proxy timeouts, so clients should reconnect.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →