Skip to content

Commit

Permalink
modify http2 stream limit
Browse files Browse the repository at this point in the history
increase the maximum number of streams per channel in HTTP/2 to 65535
  • Loading branch information
findstr committed May 28, 2024
1 parent f9d8c82 commit 42738e1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lualib/core/http/h2stream.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ local default_frame_size<const> = 16384
local default_window_size<const> = 65535
local client_preface = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"
local client_preface_size = #client_preface
local max_stream_per_channel<const> = 65535

local setting_field = {
[SETTINGS_ENABLE_PUSH] = "enable_push",
Expand Down Expand Up @@ -471,7 +472,7 @@ function M.httpd(handler)
streams = {},
send_hpack = hpack_new(default_header_table_size),
recv_hpack = hpack_new(default_header_table_size),
stream_max = 100,
stream_max = max_stream_per_channel,
window_size = default_window_size,
frame_max_size = default_frame_size,
--server more
Expand All @@ -496,8 +497,15 @@ local function open_stream(ch)
end
end
local id = ch.stream_idx
if id > 0x7ffffffff then
id = 0
while true do
if id > 0x7ffffffff then
id = 0
end
if ch.streams[id] then
id = id + 2
else
break
end
end
ch.stream_idx = id + 2
local stream = setmetatable({
Expand Down Expand Up @@ -530,7 +538,7 @@ function M.new(scheme, socket)
streams = {},
send_hpack = false,
recv_hpack = false,
stream_max = 1000,
stream_max = max_stream_per_channel,
window_size = default_window_size,
frame_max_size = default_frame_size,
--client more
Expand Down

0 comments on commit 42738e1

Please sign in to comment.