From 420962c220a9dc00b1eab7516e557c84d488790d Mon Sep 17 00:00:00 2001 From: Doug Fawley Date: Tue, 10 Sep 2019 10:08:55 -0700 Subject: [PATCH 1/2] server: set and advertise max frame size of 16KB --- internal/transport/http2_server.go | 5 ++++- internal/transport/http_util.go | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/transport/http2_server.go b/internal/transport/http2_server.go index 99396934acfd..33686a11ab95 100644 --- a/internal/transport/http2_server.go +++ b/internal/transport/http2_server.go @@ -137,7 +137,10 @@ func newHTTP2Server(conn net.Conn, config *ServerConfig) (_ ServerTransport, err } framer := newFramer(conn, writeBufSize, readBufSize, maxHeaderListSize) // Send initial settings as connection preface to client. - var isettings []http2.Setting + isettings := []http2.Setting{{ + ID: http2.SettingMaxFrameSize, + Val: http2MaxFrameLen, + }} // TODO(zhaoq): Have a better way to signal "no limit" because 0 is // permitted in the HTTP2 spec. maxStreams := config.MaxStreams diff --git a/internal/transport/http_util.go b/internal/transport/http_util.go index 9d212867ce2e..8f5f3349d906 100644 --- a/internal/transport/http_util.go +++ b/internal/transport/http_util.go @@ -667,6 +667,7 @@ func newFramer(conn net.Conn, writeBufferSize, readBufferSize int, maxHeaderList writer: w, fr: http2.NewFramer(w, r), } + f.fr.SetMaxReadFrameSize(http2MaxFrameLen) // Opt-in to Frame reuse API on framer to reduce garbage. // Frames aren't safe to read from after a subsequent call to ReadFrame. f.fr.SetReuseFrames() From b2eaf339f23391542b28f3078b2ac8121fa804f2 Mon Sep 17 00:00:00 2001 From: Doug Fawley Date: Tue, 10 Sep 2019 13:31:24 -0700 Subject: [PATCH 2/2] respect maximum frame size of 16KB in channelz test --- test/channelz_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/channelz_test.go b/test/channelz_test.go index ebbb3e54b9e8..593fc9479567 100644 --- a/test/channelz_test.go +++ b/test/channelz_test.go @@ -854,7 +854,11 @@ func doServerSideInitiatedFailedStreamWithClientBreakFlowControl(tc testpb.TestS } // sleep here to make sure header frame being sent before the data frame we write directly below. time.Sleep(10 * time.Millisecond) - payload := make([]byte, 65537) + payload := make([]byte, 16384) + dw.getRawConnWrapper().writeRawFrame(http2.FrameData, 0, tc.(*testServiceClientWrapper).getCurrentStreamID(), payload) + dw.getRawConnWrapper().writeRawFrame(http2.FrameData, 0, tc.(*testServiceClientWrapper).getCurrentStreamID(), payload) + dw.getRawConnWrapper().writeRawFrame(http2.FrameData, 0, tc.(*testServiceClientWrapper).getCurrentStreamID(), payload) + dw.getRawConnWrapper().writeRawFrame(http2.FrameData, 0, tc.(*testServiceClientWrapper).getCurrentStreamID(), payload) dw.getRawConnWrapper().writeRawFrame(http2.FrameData, 0, tc.(*testServiceClientWrapper).getCurrentStreamID(), payload) if _, err := stream.Recv(); err == nil || status.Code(err) != codes.ResourceExhausted { t.Fatalf("%v.Recv() = %v, want error code: %v", stream, err, codes.ResourceExhausted)