Skip to content

accept websocket close code 1014 (bad gateway)#3099

Open
sahvx655-wq wants to merge 1 commit into
boostorg:developfrom
sahvx655-wq:close-code-1014
Open

accept websocket close code 1014 (bad gateway)#3099
sahvx655-wq wants to merge 1 commit into
boostorg:developfrom
sahvx655-wq:close-code-1014

Conversation

@sahvx655-wq

Copy link
Copy Markdown
Contributor

While going over how the websocket layer validates incoming close frames I compared is_valid_close_code in websocket/detail/frame.hpp against the IANA WebSocket Close Code registry and found 1014 sitting in the reserved group alongside 1004/1005/1006/1015 and reported as invalid. Its neighbours 1012 (service_restart) and 1013 (try_again_later) were registered in the same batch after the original RFC 6455 table and are already accepted, so the grouping is just stale: 1014 was genuinely reserved when this code was written and has since been assigned to "Bad Gateway", the upstream-failure analogue of HTTP 502. A peer such as a gateway or reverse proxy that signals an upstream failure with 1014 therefore has its Close frame rejected in read_close with error::bad_close_code, and the connection is failed with a protocol error (1002) rather than completing the closing handshake, so the real reason for the closure is lost.

The fix accepts 1014 on receipt and renames the reserved2 enumerator to bad_gateway so it reads beside service_restart and try_again_later and matches how 1012/1013 are already handled. Received close codes are only ever vetted through is_valid_close_code, so the change stays in that one helper; 1015 keeps returning false because it remains reserved and must not appear on the wire. The test gains assertions for both sides of the boundary so 1014 cannot quietly slip back into the reserved set.

@codecov

codecov Bot commented Jun 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.25%. Comparing base (736daa0) to head (90562b4).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3099      +/-   ##
===========================================
- Coverage    93.28%   93.25%   -0.03%     
===========================================
  Files          177      177              
  Lines        13750    13750              
===========================================
- Hits         12827    12823       -4     
- Misses         923      927       +4     
Files with missing lines Coverage Δ
include/boost/beast/websocket/detail/frame.hpp 100.00% <ø> (ø)
include/boost/beast/websocket/rfc6455.hpp 100.00% <ø> (ø)

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 736daa0...90562b4. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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