The problem is that I cannot connect to the server socket on the hero.

public static void main(String[] args) { try { int port = Integer.parseInt(System.getenv("PORT")); ServerSocket serverSocket = new ServerSocket(port); System.out.println("Server running " + serverSocket.getLocalPort() + " port..."); //куча весёлого кода } } 

Connecting with

 Socket socket = new Socket(ip, port); 

I get

 java.net.ConnectException: Connection timed out (Connection timed out) 

The server can connect to itself without problems, but from the outside there are already problems. How to fix? Is it even possible for a hero to connect to server sockets?

  • Dina handle only http traffic. - Sergey Gornostaev
  • Those. on heroku nothing? - Eugene
  • Yes, look for a full-fledged hosting, not PaaS. - Sergey Gornostaev

1 answer 1

The code should have a string (and possibly in an infinite loop):

 Socket socket = serverSocket.accept();