Deploying a TCP Server in Heroku

I have a TCP server encoded in node.js. I would like to express this on Heroku because it is a free service and I do not need anything other than offering their free plan.

Now I know very little about the inner workings of Heroku, and I'm pretty new to this, so I have a few questions.

First, is it even possible to deploy TCP (non-web server)? I read that Heroku does not like node.js net because it does not support websites and that I have to use socket.io.

So, I switched my server to socket.io. I think. Because my code more or less looks the same. I did it too: https://devcenter.heroku.com/articles/using-socket-io-with-node-js-on-heroku

What do I insert into my Procfile instead of "web"? In addition, when I tried to deploy what I have, the logs reported that my application could not be bound to $ PORT. Which $ PORT? And how do I change it to the port I want?

Actually, if I do not change it, how do I know what it is, so my application can connect to this server?

+4
source share
1 answer

Heroku does not support a common TCP server, but you can get the necessary functionality using socket.io.

You need to put the website in your Procfile. This is what allows Heroku to connect an external connection to port 80 with a local port to which your web traffic will come. You will find this port by looking at the $ PORT environment variable. See here for more details: https://devcenter.heroku.com/articles/nodejs

+3
source

Source: https://habr.com/ru/post/1500380/


All Articles