岁月_Ben 2020-01-17 10:06 采纳率: 33.3%
浏览 693

node.js express框架使用https,过一段时间会卡死

用的腾讯云,申请过https后
使用express框架搭建

var privateKey  = fs.readFileSync(path.join(__dirname, './123.key'), 'utf8');
var certificate = fs.readFileSync(path.join(__dirname, './123.crt'), 'utf8');
var credentials = {key: privateKey, cert: certificate};

var SSLPORT = 443;
var httpsServer = https.createServer(credentials, app);

httpsServer.listen(SSLPORT, function() {
 console.log('HTTPS Server is running on: https://localhost:%s', SSLPORT);

 })

使用过一段时间发现项目会占用很大的cpu和内存,导致卡死,
重启也没用,必须把https代码删除再次重启运行就好了

一般过几天出现一次
猜测内存溢出,但是我通过腾讯云后台管理重启还是不行,
必须要去掉代码才可以。。。然后过一天我在把代码加上又好了

不知道什么情况,求大神们指导

  • 写回答

1条回答 默认 最新

  • @baby张 2020-01-17 10:26
    关注

    你可以用needle,http的包,对你原项目改动不大,跟用axios一样简单方便,我们好几个项目里用没用都问题, 链接 https://www.npmjs.com/package/needle

    评论

报告相同问题?