Search code examples
node.jsopenshiftopenshift-3openshift-online

How to get require('http').createServer().listen(port).on('connect', fn) to work on Openshift 3 Online?


const http = require('http');
const server = http.createServer(...).listen(8080);
server.on('connect', (req, cltSocket, head) => {
  console.log('This step will never be activated!');
  ...
  if (...) {
    let srvSocket = net.connect('9999', '127.0.0.1', () => {
      cltSocket.write('\r\n\r\n');
      srvSocket.write(head);
      srvSocket.pipe(cltSocket);
      cltSocket.pipe(srvSocket);
    });
  }
});

On Openshift 3 Online require('http').createServer().listen(port).on('connect', fn) will never be activated. Do anyone knows the mechanism behind this challenging behavior and how to resolve it?

P.S. This is not really a duplicated question because in "How to open an internal port in Openshift 3 Online" the question is about opening an internal port. The extended question is "How to get require('http').createServer().listen(port).on('connect', fn) to work on Openshift 3 Online."


Solution

  • Openshift Online blocks 'connect' event, its reverse proxy handles it and returns a 502 error. The event never reaches your pod.