我在 Node JS 10.9 中使用 HAPI JS 和 HTTP/2。当我使用这个例子启动服务器时,
const fs = require('fs')
const Hapi = require('hapi')
const http2 = require('http2')
const server = new Hapi.Server()
server.connection({
listener: http2.createServer(),
host: 'localhost',
port: 3000
})
server.route({
method: 'GET',
path:'/hello',
handler: function (request, reply) {
return reply('Hello, World!')
}
})
server.start((err) => {
if (err) console.error(err)
console.log(`Started ${server.connections.length} connections`)
})
我在控制台上收到这个警告
(node:16600) ExperimentalWarning: The http2 module is an experimental API.
我在网上找不到相关说明是否可以在生产模式下使用?在出现此类警告的情况下,可以在生产模式下使用 HTTP/2 吗?
最佳答案
正如@DoMiNeLa10 指出的那样,实验性警告已在 10.10 中删除:
https://github.com/nodejs/node/pull/22716 :
http2:
◦ The http2 module is no longer experimental. #22466
关于使其成为非实验性所涉及的所有工作的良好讨论:https://github.com/nodejs/node/issues/19453
关于javascript - 实验警告 : The http2 module is an experimental API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52254893/