Repository navigation
Description
Title: HttpConnectionManager max_requests_per_connection behaving different from the documented behaviour
Description:
I have an Istio use case on long lived connections, which I am trying to test by applying envoy filter with max_requests_per_connection=3, with default drain timeout of 5sec. This is not working as per the behaviour explained at https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto#envoy-v3-api-field-extensions-filters-network-http-connection-manager-v3-httpconnectionmanager-drain-timeout
A simple HTTP2 client sends GETs in a loop, when GOAWAY is received from server, it ignores it and keeps using connection.
Expected result: After 3 GET requests, server initiates connection drain, it sends a first GOAWAY message with “Promised-Stream-ID: 2147483647”, and if connection is not closed prior 5 seconds, it sends a second GOAWAY with “Promised-Stream-ID: 5 (2 x max_requests_per_connectionx - 1)”, and closes connection 1 second later.
Result: Not OK, after 3 GET requests server just sends the first GOAWAY message, as GETs are received continuously, no GOAWAY with “Promised-Stream-ID: 5 (2 x max_requests_per_connectionx - 1)” is sent and connection is never closed.
As per the drain_timeout document:
During the grace period, Envoy will continue to accept new streams. After the grace period, a final GOAWAY frame is sent and Envoy will start refusing new streams
But from the captured pkg, the final GOAWAY does not send, and envoy also does not refuse new streams. So this looks like an issue to me.
Repro steps:
- Apply the below EnvoyFilter:
kind: EnvoyFilter
metadata:
name: lb-downstream
namespace: istio-system
spec:
workloadSelector:
labels:
istio: ingressgateway
configPatches:
- applyTo: NETWORK_FILTER
match:
context: GATEWAY
listener:
filterChain:
filter:
name: "envoy.filters.network.http_connection_manager"
patch:
operation: MERGE
value:
typed_config:
"@type": "type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager"
common_http_protocol_options:
max_requests_per_connection: 3 # can be set as per SM user's need
2) Use the below script to keep sending http2 requests to the server, and ignore the response. (Note that the GETs are sent continuously without waiting for the drain timeout window, and in such cases, we see that the connection is never closed)
#!/usr/bin/python
import time
from hyper import HTTP20Connection
count = 0
conn = HTTP20Connection('localhost:80')
while True:
id = conn.request('GET', '/server1/
time.sleep(2)
Logs:
Attaching the Wireshark capture for the scenario.

Activity
rojkov commentedon Nov 19, 2021
Thank you for the great description!
cc @alyssawilk @htuch
YaoZengzeng commentedon Nov 20, 2021
The cause of the problem appears to be that the new coming streams will keep resetting drain_timer_ which result it never timeout, ref https://github.com/envoyproxy/envoy/blob/main/source/common/http/conn_manager_impl.cc#L293 .
I'd like to fix it:)
kfaseela commentedon Nov 20, 2021
@YaoZengzeng : Thanks for the response, and would be really helpful if you are planning to fix it. :)
kfaseela commentedon Nov 20, 2021
Thank you @rojkov :) This is my first activity in the community, and happy to receive a nice response!
http2: drain only once when reached max_requests_per_connection (#19078)
http2: drain only once when reached max_requests_per_connection (envo…
http2: drain only once when reached max_requests_per_connection (envo…