Add example for enabling TCP keepalive via socket_options - #2699
Conversation
Configuration.socket_options is already wired through to urllib3, but there is no example showing how to use it. Long-lived watches and log streams can hang when a connection is silently dropped; TCP keepalive lets the kernel detect the dead peer. Add an example and list it in the examples README. Fixes kubernetes-client#2067
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: thev1ndu The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Invalid commit message issues detected Invalid commit messagesKeywords which can automatically close issues and hashtag(#) mentions are not allowed.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
TCP_KEEPALIVE is not the right solution, it does not work as people thing it does, once the connection is established the keepalives are not sent periodically ... http2 ping frames is the solution to idle connections and middleware silent drops kubernetes/kubernetes#95981 |
What type of PR is this?
/kind documentation
What this PR does / why we need it:
Configuration.socket_optionsis already passed through to the underlying urllib3 pool, but there is no example showing how to use it. Long-lived requests such as watches orfollow=Truelog streams can hang when a connection is silently dropped by a load balancer or firewall. Enabling TCP keepalive lets the kernel detect the dead peer and close the socket. This addsexamples/tcp_keepalive.pyand lists it in the examples README. The helper only sets the platform-specific options (TCP_KEEPIDLEand friends) when they are available.Which issue(s) this PR fixes:
Fixes #2067
Special notes for your reviewer:
Example only, no library code changes.
Does this PR introduce a user-facing change?