Skip to content

fix(docker): healthcheck WebSocket probe for Phoenix/Bandit#2167

Open
davidyuk wants to merge 1 commit intoaeternity:masterfrom
davidyuk:fix/docker-healthcheck-websocket
Open

fix(docker): healthcheck WebSocket probe for Phoenix/Bandit#2167
davidyuk wants to merge 1 commit intoaeternity:masterfrom
davidyuk:fix/docker-healthcheck-websocket

Conversation

@davidyuk
Copy link
Copy Markdown
Member

@davidyuk davidyuk commented Mar 19, 2026

Problem

Docker healthcheck WebSocket probes were failing: the server returns 400 Bad Request instead of 426 Upgrade Required.

Phoenix (with Bandit) changed behavior in phoenixframework/phoenix#5621: invalid or incomplete WebSocket handshakes now get 400 (RFC-compliant) instead of 426 (Cowboy’s previous behavior). The healthcheck was sending an incomplete handshake (no Sec-WebSocket-Key, Connection: close instead of Upgrade), so the server correctly responded with 400 and the check failed.

Solution

  • Send a valid WebSocket upgrade request (Connection: Upgrade, Upgrade: websocket, Sec-WebSocket-Key, Sec-WebSocket-Version: 13) and expect 101 Switching Protocols.
  • Extract the common WebSocket check into a ws_check() function.
  • Fix DEPRECATED_SWAGGER_RES condition to require "0" explicitly (was truthy check).
  • Use -sS -m 0.5 on curl for quiet output and a 1s timeout.

Testing

Run the healthcheck against a running MDW container (e.g. started with docker-compose); both /websocket and /v2/websocket should pass when the WebSocket server is up.

- Send full WebSocket handshake (Connection: Upgrade, Sec-WebSocket-Key,
  Sec-WebSocket-Version) and expect 101 Switching Protocols.
  Phoenix/Bandit return 400 for incomplete handshakes (RFC-compliant)
  instead of 426 that Cowboy used to return.
- Extract common WebSocket check into ws_check().
- Fix DEPRECATED_SWAGGER_RES condition to require "0" explicitly.
- Use -sS -m 0.5 on curl for quiet run and timeout.
@davidyuk davidyuk force-pushed the fix/docker-healthcheck-websocket branch from 4d71ab3 to ae70506 Compare March 19, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant