Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Support for setting keepAliveTimeout

未關閉
#103 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
72/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
冷清
技術堆疊
docker, node.js
領域
backend

研究方向

相關進入點是建立 httpServer 和 httpsServer 的 HTTP/HTTPS 伺服器設定;先追蹤 Echo 容器如何讀取執行階段環境變數。為兩個伺服器加入可設定的 keep-alive 逾時,包括 issue 中顯示的相關 headers-timeout 行為,並確認無論是否設定此項,容器都仍能啟動並接受 HTTP/S 請求。

由索引模型根據 Issue 內容生成。

描述

Hi,

I was making some tests with the Echo container, including ensuring connection pool logics / configuration.
Currently this is taking the default 5s Node keepAliveTimeout which will then start dropping connections. If we would be able to stablish the keepAliveTimeout we would be able to allow the consumer side to manage the connections.

I've hacked a solution as:

// How long an idle keep-alive connection is held before the server closes it.
// Node's default is 5s, so an upstream keep-alive pool in front of this server can never be observed intact. 
// Raising it past the drain time lets the pool settle and leaves the reverse proxy in charge of trimming it.
const keepAliveTimeoutMs = parseInt(process.env.KEEPALIVE_TIMEOUT_MS, 10);
if (Number.isFinite(keepAliveTimeoutMs) && keepAliveTimeoutMs > 0) {
    for (const server of [httpServer, httpsServer]) {
        server.keepAliveTimeout = keepAliveTimeoutMs;
        // headersTimeout bounds how long a started request may take to send its headers; 
        // keeping it above keepAliveTimeout stops Node from closing a pooled connection just as it is being reused.
        server.headersTimeout = keepAliveTimeoutMs + 5000;
    }
    console.log(`Keep-alive timeout set to ${keepAliveTimeoutMs}ms (headers timeout ${keepAliveTimeoutMs + 5000}ms).`);
}
主要語言
Shell
星號
792
分支
152
平均合併
3 天 18 小時
30 天內合併 PR
3

貢獻指南

這個儲存庫沒有索引到貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

mendhak/docker-http-https-echo 的其他 Issue

查看 mendhak/docker-http-https-echo 的全部 Issue

相似的 Issue

更多 Shell/Bash Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。