【问题标题】:node express server is getting crashed - http2节点快递服务器正在崩溃 - http2
【发布时间】:2016-10-28 17:26:03
【问题描述】:

node express 服务器在访问应用程序时因以下错误而崩溃。 (我已经使用“npm start”来启动服务器)

网址:https://localhost:8443/

注意:上面的 URL,http 是工作文件,https 是失败的。

我需要一些帮助来解决这个问题。

代码:

       // load the things we need
var express = require('express'),
    fs = require('fs'),
    app = express(),
    path = require('path'),
    http = require('http'),
    http2 = require('http2'),
    cookieParser = require('cookie-parser'),
    bodyParser = require('body-parser'),
    httpServer, http2Server;

var compress = require('compression');
app.use(compress());
app.use(cookieParser());

// instruct the app to use the `bodyParser()` middleware for all routes
app.use(bodyParser.urlencoded({
    extended: true
}));

app.use(bodyParser.json());

// set the view engine to ejs
app.use(express.static(path.join(__dirname, 'public'), {
    maxAge: 86400000
}));

app.set('views', path.join(__dirname, 'public/views'));
// app.set('views', __dirname + '/public/views');
app.engine('html', require('ejs').renderFile);
//app.set('view engine', 'ejs');

// use res.render to load up an ejs view file

app.get('/', function(req, res) {
    res.redirect('/dashboard');
});


httpServer = http.createServer(app).listen(5555, function() {
    console.log("Express server listening on port " + 5555);
});

var privateKey = fs.readFileSync('./sol.com.key', 'utf8');
var certificate = fs.readFileSync('./sol.com.crt', 'utf8');
var credentials = { key: privateKey, cert: certificate };

http2Server = http2.createServer(credentials, app).listen(8443, function() {
    console.log("Express server http2 listening on port " + 8443);
});

错误:

Express server http2 listening on port 8443
_stream_readable.js:517
    dest.end();
         ^

TypeError: dest.end is not a function
    at Stream.onend (_stream_readable.js:517:10)
    at Stream.g (events.js:286:16)
    at emitNone (events.js:91:20)
    at Stream.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:934:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

npm ERR! Darwin 15.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.2.2
npm ERR! npm  v3.9.5
npm ERR! code ELIFECYCLE
npm ERR! app@1.0.0 start: `node app.js`
npm ERR! Exit status 1

【问题讨论】:

    标签: javascript node.js http express http2


    【解决方案1】:

    express 尚不支持 http/2,遗憾的是没有预计何时支持。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-16
      • 2012-12-27
      • 2015-06-14
      • 2015-09-22
      • 1970-01-01
      • 2020-11-05
      相关资源
      最近更新 更多