Skip to content

WebSocket

Introduction to WebSocket

WebSocket is a communication protocol that operates over a single TCP connection, enabling real-time data transfer between a web browser and a server. It's compatible with HTTP and works over ports 443 and 80, using the HTTP Upgrade header to transition from HTTP to WebSocket. As a result, WebSocket provides a more efficient and standardized solution for two-way browser-server communication.

Upgrading to WebSocket

Application workloads that run in MedStack Control clusters can upgrade client's HTTP connections to WebSocket. On MedStack Control, this is purely application layer implementation. Simply ensure that the Docker service facilitating the WebSocket connection has the necessary tools to upgrade the TCP connection.

The headers forwarded from the load balancer are:

  • X-Forwarded-For
  • X-Real-IP
  • X-Forwarded-Proto
  • X-Forwarded-Port
  • X-Forwaded-Host
  • X-Forwarded-Server

The code that re-writes the request headers can be found here. Some headers depend on certain conditions.

Traefik load balancer proxying connections

The managed load balancer (Traefik) that make applications running in MedStack Control clusters accessible to the open internet passes through the HTTP header required to upgrade a TCP connection to WebSocket.

Traefik does not require custom configuration to support WebSocket upgrades. However, it is important to note that Traefik is not configured to support sticky sessions.