smart-image-scraper-mcp 2.11.2 → 2.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/infrastructure/httpClient.js +11 -15
package/package.json
CHANGED
|
@@ -9,24 +9,20 @@ import https from 'https';
|
|
|
9
9
|
import config from '../config/index.js';
|
|
10
10
|
import logger from './logger.js';
|
|
11
11
|
|
|
12
|
-
// HTTP
|
|
13
|
-
//
|
|
12
|
+
// HTTP 连接配置 - 禁用 keepAlive 避免连续调用时 socket 耗尽
|
|
13
|
+
// MCP 每次调用独立,keepalive 复用收益小,反而导致连接池堵塞
|
|
14
14
|
const httpAgent = new http.Agent({
|
|
15
|
-
keepAlive:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
scheduling: 'lifo', // 后进先出,优先使用最近的连接
|
|
20
|
-
timeout: 10000, // 空闲连接10秒后关闭
|
|
15
|
+
keepAlive: false, // 禁用 Keep-Alive,用完立即释放
|
|
16
|
+
maxSockets: 15, // 最大并发连接数
|
|
17
|
+
maxFreeSockets: 0, // 不保留空闲连接
|
|
18
|
+
scheduling: 'fifo', // 先进先出,公平分配
|
|
21
19
|
});
|
|
22
20
|
|
|
23
21
|
const httpsAgent = new https.Agent({
|
|
24
|
-
keepAlive:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
scheduling: 'lifo',
|
|
29
|
-
timeout: 10000, // 空闲连接10秒后关闭
|
|
22
|
+
keepAlive: false, // 禁用 Keep-Alive
|
|
23
|
+
maxSockets: 15,
|
|
24
|
+
maxFreeSockets: 0,
|
|
25
|
+
scheduling: 'fifo',
|
|
30
26
|
rejectUnauthorized: false, // 允许自签名证书
|
|
31
27
|
});
|
|
32
28
|
|
|
@@ -47,7 +43,7 @@ const httpClient = axios.create({
|
|
|
47
43
|
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
|
|
48
44
|
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
|
|
49
45
|
'Accept-Encoding': 'gzip, deflate, br',
|
|
50
|
-
'Connection': '
|
|
46
|
+
'Connection': 'close', // 用完关闭,避免 socket 泛滥
|
|
51
47
|
},
|
|
52
48
|
maxRedirects: 5,
|
|
53
49
|
validateStatus: (status) => status < 500,
|