Skip to content

fix(server): free socket timeout caused socket hang up#407

Merged
bzp2010 merged 1 commit intomainfrom
bzp/fix-free-socket-timeout
Feb 4, 2026
Merged

fix(server): free socket timeout caused socket hang up#407
bzp2010 merged 1 commit intomainfrom
bzp/fix-free-socket-timeout

Conversation

@bzp2010
Copy link
Copy Markdown
Collaborator

@bzp2010 bzp2010 commented Feb 4, 2026

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

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible

@bzp2010 bzp2010 added the test/apisix-standalone Trigger the APISIX standalone test on the PR label Feb 4, 2026
@bzp2010 bzp2010 merged commit 2b9f9c0 into main Feb 4, 2026
42 of 43 checks passed
@bzp2010 bzp2010 deleted the bzp/fix-free-socket-timeout branch February 4, 2026 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test/apisix-standalone Trigger the APISIX standalone test on the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

help request: failed to execute adc command

3 participants