dyatesdude dyatesdude - 3 months ago 121
Java Question

Heroku- Web process failed to bind to $PORT within 90 seconds of launch. TooTallNate Websockets

I'm using a tootallnate websockets server listening for connections from a website.

How do I make a connection to my server on heroku?

When my website tries to connect at

wss://Heroku-Name-39329.herokuapp.com/


or

wss://Heroku-Name-39329.herokuapp.com:5000/


My heroku logs output.

at=error code=H10 desc="App crashed" method=GET path="/" host=wss://Heroku-Name-39329.herokuapp.com request_id=4afca002-2078-439c-85dc-ad6ef7db50d2 fwd="207.244.77.23" dyno= connect= service= status=503 bytes=


And then(Still Heroku Logs)

Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
Stopping process with SIGKILL
Process exited with status 137
State changed from starting to crashed
State changed from crashed to starting
Starting process with command `java $JAVA_OPTS -cp target/classes/:target/dependency/* v1.a1.server


My javascript logs

WebSocket connection to 'wss://Heroku-Name-39329.herokuapp.com/:5000/' failed: Establishing a tunnel via proxy server failed.


My Apps set within the server are.

String host = "";
int port = 5000;


My Procfile

web: java $JAVA_OPTS -cp target/classes/:target/dependency/* v1.a1.server

Answer

Try using this:

String host = "0.0.0.0";
int port = System.getenv("PORT");

On Heroku, you must bind to 0.0.0.0 and use the port assigned to your app, which is contained in the $PORT environment variable.

From the client, you will not need to specify a port, so only wss://Heroku-Name-39329.herokuapp.com/ should be used (not the one with 5000).