fix(server): free socket timeout caused socket hang up#407
Merged
Conversation
juzhiyuan
approved these changes
Feb 4, 2026
guoqqqi
approved these changes
Feb 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes apache/apisix-ingress-controller#2704
APISIX and its Helm chart both set the nginx client-side keepalive_timeout to 60s, instead of nginx's default value of 75s.
Therefore, if ADC uses the same 60s, we may frequently encounter a socket hang-up error. This is because by the time the downstream (ADC) attempts to reuse the connection, the upstream (APISIX Admin API) has already closed it. This causes the sync to fail.
Regarding nginx keepalive_timeout, this mechanism is at the application level. Node.js, which ADC is based on, silently sends TCP Keep-Alive packets to maintain the TCP connection. These packets are handled by the remote Linux Kernel without triggering any events on the application socket. Therefore, if no actual HTTP requests are sent within a 60s period, nginx will close the connection, which results in the socket hang up error.
This PR sets the maximum idle time for the socket to 50s; if it is not used again within 50s, it will be marked for release. This prevents client errors caused by the server side actively terminating the connection.
Note that while this PR supports overriding this value via an environment variable, you should not rely on it. We may modify or remove these variables at any time without notice. This is an internal matter, and we are under no obligation to guarantee the internal implementation will remain consistent. Please use the officially distributed APISIX Ingress Controller Helm chart. Build it yourself only if you understand what you are doing and the risks involved.
I will initiate another proposal on APISIX to explore setting the default keepalive_timeout to the nginx default value of 75 seconds.
Checklist