Reputation: 10993
I have created my first Node.js application which consists of two Express servers, each listening on a different port. The reason for two server instances with different ports is because one server is used for general browser access, and the other is a 'machine interface' server that embedded devices connect to.
When deploying on Openshift, I have learned that the listening port must be process.env.OPENSHIFT_NODEJS_PORT
. This is no problem: I can redesign my application to cope with this by simply using one server instance and making use of routes, since HTTP is used in both cases.
I am curious however about the following point: If I choose to create a Node.js application that needs to listen on a non-HTTP port, particularly if it used some proprietary TCP protocol of my own, then what are my options? Is it the case that most public hosting platforms are geared specifically for web applications, and I'd have to seek specialist / dedicated machine hosting to support arbitrary ports? Or, am I doing it wrong? In other words, is it unconventional to deploy a Node.js application that listens on arbitrary / non-HTTP(S) ports?
There is a very similar question being asked here though the answer only focuses on the topic of Websockets.
Upvotes: 2
Views: 722
Reputation: 53
I don't think you'd be able to do this with the standard NodeJS cartridge, but you could setup your own cartridge with different port mappings to expose different ports to the public proxy.
Take a look at the Cartridge Development Guide, particularly section 7. Exposing Services / TCP Endpoints:
https://docs.openshift.org/origin-m4/oo_cartridge_developers_guide.html#endpoints
Upvotes: 2