I am creating a very simple Server using Java's Socket API, and have deployed it to Heroku. I've hardcoded the value of the port at which the server will listen for incoming connections. My app is deployed perfectly fine, and from the logs I can see it is also running properly. The problem is that, when I try to connect to that server, I receive a connection timeout error from the client code which I wrote, after waiting for a few seconds. It seems that the Server deployed on Heroku is not able to receive any incoming connections on the specified port. How could I make this work?
Asked
Active
Viewed 31 times
0
-
I don't use Heroku but you shouldn't hardcode the port but rather read it from the configuration. See https://stackoverflow.com/questions/28706180/setting-the-port-for-node-js-server-on-heroku – Juraj Martinka Apr 11 '22 at 07:03
-
I have changed the code to read the port number from the environment variable. Still the issue persists :-( Its not helpful as the port now keeps on changing and I can't always re-configure the client to fetch the port of the server before connecting to it. – Aayush Anand Apr 18 '22 at 15:04
-
Can you add more details about what exactly you did and perhaps some logging to your server app to check the port config it receives? – Juraj Martinka Apr 19 '22 at 11:01