超时NodeJS Express HTTPS不可更改?

时间:2018-06-17 08:50:12

标签: javascript node.js http express https

我希望设置超时,但只能使用HTTP服务器。

我的代码:

if (options.web_server_encryption === true) {
    if (options.dev == 0) {
        var httpserver = http.createServer(greenlock.middleware(function (req, res) {
            try {
                res.writeHead(301, {"Location": "https://" + req.headers['host'] + req.url})
            } catch (e) {
                console.log(e)
            }
            res.end()
        })).listen(options.http_port, function () {
            logger.info(stringbuilder.ldmb("httpstart", options));
        });
        httpserver.timeout = 5000;
        optionsdevcsfs = greenlock.httpsOptions;
    } else {
        var httpserver = http.createServer(function (req, res) {
            try {
                res.writeHead(301, {"Location": "https://" + req.headers['host'] + req.url})
            } catch (e) {
                console.log(e)
            }
            res.end()
        }).listen(options.http_port, function () {
            logger.info(stringbuilder.ldmb("httpstart", options));
        });
        httpserver.timeout = 5000;
        optionsdevcsfs = {key: options.key, cert: options.cert};
    }

    var httpsserver = https.createServer(optionsdevcsfs, app).listen(options.https_port, function () {
        logger.info(stringbuilder.ldmb("httpsstart", options));
    });
    httpsserver.timeout = 5000;
} else if (options.web_server_encryption === false) {
    app.listen(options.http_port, function () {
        logger.info(stringbuilder.ldmb("httpstart", options));
    });
} else {
    logger.error(stringbuilder.ldmb("httpnotstart"));
}

if (options.wse_server_encryption === true) {
    var server = https.createServer(optionsdevcsfs, wse).listen(options.wse_port, function () {
        logger.info(stringbuilder.ldmb("wssstart", options)); //wss
        wseinit();
    });
    server.timeout = 5000;
} else if (options.wse_server_encryption === false) {
    var server = http.createServer(wse).listen(options.wse_port, function () {
        logger.info(stringbuilder.ldmb("wssstart", options)); //ws
        wseinit();
    });
    server.timeout = 5000;
} else {
    logger.error(stringbuilder.ldmb("wssnotstart"));
}

我用命令测试它:

time nc test.trackhe.de 443

我在端口80上有5秒钟,在另一个端口上有2分钟超时 - 我猜是默认值。我尝试使用 env.production 位,它没有效果。

0 个答案:

没有答案