nodejs tls代理同一端口其他协议
我希望将HTTP与同一端口中的RTMPS协议一起使用。因此,我决定使用TLS服务器。
HTTPS与Chrome浏览器合作良好,但我面临Postman Call的问题。
而且我还无法测试RTMPS协议;我需要做更多...
const app = express()
const listener = {}
/***
app configure codes
**/
listener[443] = HttpRoute.createServer(app)
listener['tls_443'] = tls.createServer({
ALPNProtocols: ['http/1.1', 'http/1.0', 'http/2', 'http/2.0'],
allowHalfOpen: true,
rejectUnauthorized: false
}, (socket) => {
socket.on('error', (e) => {
log().error(utils.recordError(e)) // -> error recoded
})
socket.setKeepAlive(true, 0)
if(socket.alpnProtocol && socket.alpnProtocol.startsWith('http')) {
if(listener[443])
listener[443].emit('connection', socket)
} else {
// TODO: rtmp -> will be add rtmp session control
socket.end()
}
}).listen(443)
updateCert() // => listener['tls_443'].setSecureContext({key: '****', cert: '*****'})
服务器错误实际上是
error: "Error: read ECONNRESET\n at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27)"
邮政错误日志
Error: socket hang up
Request Headers
x-converter-key: strstr
User-Agent: PostmanRuntime/7.29.0
Accept: */*
Cache-Control: no-cache
Postman-Token:
Host: ****.**.*
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
,但船上运行良好,但没有Postman请求中的ALPN数据。
I hope to using https with rtmps protocols in same port. so i decide to using TLS server.
Https was working well with chrome browser, but i facing issue with postman call.
And i couldn't test rtmps protocol, yet; I need to make more...
const app = express()
const listener = {}
/***
app configure codes
**/
listener[443] = HttpRoute.createServer(app)
listener['tls_443'] = tls.createServer({
ALPNProtocols: ['http/1.1', 'http/1.0', 'http/2', 'http/2.0'],
allowHalfOpen: true,
rejectUnauthorized: false
}, (socket) => {
socket.on('error', (e) => {
log().error(utils.recordError(e)) // -> error recoded
})
socket.setKeepAlive(true, 0)
if(socket.alpnProtocol && socket.alpnProtocol.startsWith('http')) {
if(listener[443])
listener[443].emit('connection', socket)
} else {
// TODO: rtmp -> will be add rtmp session control
socket.end()
}
}).listen(443)
updateCert() // => listener['tls_443'].setSecureContext({key: '****', cert: '*****'})
server error was
error: "Error: read ECONNRESET\n at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27)"
Postman error log
Error: socket hang up
Request Headers
x-converter-key: strstr
User-Agent: PostmanRuntime/7.29.0
Accept: */*
Cache-Control: no-cache
Postman-Token:
Host: ****.**.*
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Actually that was working well, but don't has ALPN data from Postman request.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论