'Nodejs tls proxy same port other protocol

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.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source