Skip to content

transport: enforce HTTP/2 receive window (http2 5.4) - #2059

Open
sh-agents wants to merge 28 commits into
simplex-chat:masterfrom
sh-agents:sh/http2-5
Open

sh-agents wants to merge 28 commits into
simplex-chat:masterfrom
sh-agents:sh/http2-5

Conversation

@sh-agents

@sh-agents sh-agents commented Nov 13, 2026 •

Copy link
Copy Markdown

Received HTTP/2 data is limited to the advertised flow-control window: a peer that sends more is disconnected with GOAWAY ENHANCE_YOUR_CALM. For this, http2 is upgraded to 5.4.13, together with tls 2.1.6, network 3.2 and warp 3.4.

The tls upgrade of #1620 is continued here; it was stopped at a test failure between tls 2.1.6 and 2.1.7, so tls is pinned to 2.1.6.

Dependencies

  • http2 4.2.2 → 5.4.13, network 3.1.4.0 → 3.2.12.0, time-manager 0.0.1 → 0.5.2, tls 1.9.0 → 2.1.6.
  • warp 3.3.30 (fork) → 3.4.21 and warp-tls 3.4.7 (git) → 3.4.18, from Hackage. The change of the fork, a timed-out connection thread killed without its socket being closed, is included in warp 3.4.21.
  • websockets 0.13.0.0, crypton-connection 0.4.5, tls-session-manager 0.0.9, auto-update 0.2.8; added: network-control, http-semantics.
  • index-state 2023-12-12 → 2026-11-10. Unrelated packages are upgraded with it, among them postgresql-libpq 0.11, zlib 0.7, hspec 2.11.18 and http-client 0.7.19; on GHC 9.6.3, the boot packages directory, filepath, process, unix, Cabal and Cabal-syntax are built from Hackage; on GHC 8.10.7, process and Cabal.

Code

  • The HTTP/2 server and client are configured with the 5.x ServerConfig and ClientConfig and the limits of 4.2.2: 100 concurrent streams, stream and connection windows of 1048575 bytes. SETTINGS_MAX_FRAME_SIZE, advertised as 32759 by 4.2.2, is left at the 5.x default of 16384.
  • With confReadNTimeout = True, the read path of 4.2.2 is kept: reads are not timed out by http2.
  • An HTTP/2 client is disconnected, with its disconnected action called, when the connection is closed or lost: after a read error, at end of input, and when the reader of the connection is stopped by http2 after GOAWAY of the server.
  • In 5.x, a response stream that is still open when the client callback returns is reset, and its unread body is discarded. sendRequest takes a handler, in which the body is read; in XFTP downloads, the file is written in it. The sendReq field of HTTP2Client has the polymorphic type H.SendRequest, so a response body can be read in its callback. sendRequestDirect has the same signature; its response is read from bodyHead, as for APNs.
  • closeTLS is limited to 1 s. It is changed in xftp-server: close stalled connections, reduce memory #2058 too, with the same implementation; the PR merged second is updated by merging master.
  • Extended master secret is required for TLS 1.2 by tls 2.1.6, on clients and servers; it is offered by tls 1.9 peers.
  • In tls 2, the Finished data is a VerifyData value. The cipher names are changed in tls 2; the ciphers are the same (0x1303, 0xCCA9).
  • Simplex.Messaging.Transport is compiled with -Wno-deprecations: getFinished and getPeerFinished are deprecated in tls 2, and Nothing is returned by their replacement getTLSUnique for TLS 1.3 sessions.

Tests

  • In a new test, raw HTTP/2 frames are sent to an HTTP/2 server with the XFTP server limits, started with runHTTP2Server: exactly the advertised window is accepted, and one more byte is answered with GOAWAY ENHANCE_YOUR_CALM. Each expected frame is awaited for at most 5 s.
  • In a new test, GOAWAY(NO_ERROR) is sent by a raw HTTP/2 server while a request is in flight. In one case the response is sent after GOAWAY and the connection is kept open; in the other the connection is closed after GOAWAY. The client is disconnected within 5 s in each case.
  • The limit of closing a TLS connection is tested in xftp-server: close stalled connections, reduce memory #2058 (testCloseBlockedTLS), which has the same closeTLS.
  • All test groups, the XFTP web client tests included, passed on GHC 9.6.3 at cf000ae: https://github.com/simplex-chat/simplexmq/actions/runs/44521085873. The head is built with GHC 9.6.3 in the reduced build of this draft, and with GHC 8.10.7 in the full build.
  • Builds of this branch (tls 2.1.6, http2 5.4.13) and of master 880d089 (tls 1.9.0, http2 4.2.2) were tested against each other on AWS, with each build as server and as client. A 10 MiB file was uploaded and downloaded with xftp, and the downloaded file was identical. An SMP connection was established between two agents through smp-server, and a message was delivered each way. TLS 1.3 with TLS_CHACHA20_POLY1305_SHA256 was negotiated in every pair.
  • Builds of simplex-chat with this simplexmq are pending: desktop and CLI, and Android and iOS with network 3.2.12.

For simplex-chat

  • In remote control (src/Simplex/Chat/Remote/Protocol.hs), the response body is read after sendRequestDirect returns. It has to be read in a callback of sendReq, so that requests are sent concurrently with the event poll.
  • simplex-chat.cabal: the bounds of http2 (>=4.2.2 && <4.3), network (>=3.1.2.7 && <3.2 and ==3.1.*), tls (>=1.9.0 && <1.10), websockets (==0.12.*) and warp (==3.3.*) are raised to the versions above.
  • cabal.project: the same index-state; the warp pin of simplex-chat/wai and the warp-tls pin of yesodweb/wai removed.
  • flake.nix: the same index-state, and the hackage input in flake.lock updated to a revision that includes 2026-11-10.
  • scripts/nix/sha256map.nix: the entries of the removed wai pins deleted.
/

@sh-agents
sh-agents marked this pull request as draft November 19, 2026 08:31
@sh-agents sh-agents changed the title deps: enforce HTTP/2 receive window (http2 5.4) transport: enforce HTTP/2 receive window (http2 5.4) Nov 19, 2026
@sh-agents
sh-agents marked this pull request as ready for review November 19, 2026 15:38

This branch has not been deployed

No deployments
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