2

问题:当我在此日志(内存)之后发送请求时,它显示“套接字挂起(connResetException)”错误。NodeJS 服务器停止工作。

[1:0x330e8a0]    22724 ms: Mark-sweep 16.4 (25.2) -> 10.6 (29.9) MB,
 3.3 / 0.0 ms  (+ 0.1 ms in 2 steps since start of marking, biggest step 0.1 
ms, walltime since start of marking 7 ms) (average mu
 = 0.999, current mu = 1.000) finalize incremental marking
 via task GC in old space requested

架构:http-proxy用作反向代理。它启用 SSO(单点登录)并将其流量发送到应用程序。

代理服务器中的错误日志(仅在生产中发生 - 更多流量)

/node_modules/http-proxy/lib/http-proxy/index.js:120
    throw err;
    ^

Error: socket hang up
    at connResetException (internal/errors.js:561:14)
    at Socket.socketCloseListener (_http_client.js:380:25)
    at Socket.emit (events.js:214:15)
    at TCP.<anonymous> (net.js:658:12) {
  code: 'ECONNRESET'
}

由于套接字挂起发生在许多情况下,我研究并尝试了各种情况。而且我认为我的节点的内存泄漏问题可能是问题所在。 每个请求的node --trace_gc src/index.js命令打印 2~3秒。allocation failure

奇怪的日志

 [1:0x449d780]    20364 ms: Scavenge 11.9 (13.2) -> 11.3 (13.2) MB, 3.2 / 0.0 ms \
     (average mu = 0.961, current mu = 0.961) allocation failure 

源代码

var apiProxy = httpProxy.createProxyServer();
app.use(cookieParser());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json())

app.use(passport.initialize({}));
app.use(passport.session({}));
app.use(session({
    secret: 'secret',
    resave: false,
    saveUninitialized: true,}
));

app.get('/source*',
    function(req, res, next) {
        req.query.RelayState = req.url;
        if(req.user) {
            apiProxy.web(req, res, {target: xx});

问题: [http-proxy expressjs]随机挂断。它通常工作两天,服务器出现 502 错误。我需要手动重启容器来恢复它。

/node_modules/http-proxy/lib/http-proxy/index.js:120
    throw err;
    ^

Error: socket hang up
    at connResetException (internal/errors.js:561:14)
    at Socket.socketCloseListener (_http_client.js:380:25)
    at Socket.emit (events.js:214:15)
    at TCP.<anonymous> (net.js:658:12) {
  code: 'ECONNRESET'
}

欢迎任何想法......请帮助

4

0 回答 0