Heroku Java application timing out after 90 seconds - java

I have been trying to host a discord bot on heroku for some time now. I Have everything set up now but the connection keeps timing out after 90 seconds because it cannot sustain a connection and I am not sure what is wrong.
Procfile: web: java $JAVA_OPTS -Dserver.port=$PORT -cp target/classes:target/dependency/* com.marcuzzo.JDABot.Bot
Error log:
2020-07-17T17:54:47.513540+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -Dserver.port=7699 -cp target/classes:target/dependency/* com.marcuzzo.JDABot.Bot`
2020-07-17T17:54:49.238091+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2020-07-17T17:54:49.241547+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2020-07-17T17:54:50.386750+00:00 app[web.1]: 938 [main] INFO net.dv8tion.jda.api.JDA - Login Successful!
2020-07-17T17:54:50.526175+00:00 app[web.1]: 1078 [JDA MainWS-WriteThread] INFO net.dv8tion.jda.internal.requests.WebSocketClient - Connected to WebSocket
2020-07-17T17:54:50.862291+00:00 app[web.1]: 1414 [JDA MainWS-ReadThread] INFO net.dv8tion.jda.api.JDA - Finished Loading!
2020-07-17T17:56:18.105532+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
2020-07-17T17:56:18.120426+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-07-17T17:56:18.198101+00:00 heroku[web.1]: Process exited with status 137
2020-07-17T17:56:18.243205+00:00 heroku[web.1]: State changed from starting to crashed
I have been told to change the dyno in my procfile to anything OTHER then web but while the build succeeds, the bot never goes online if I were to use something like bot.
This post tells me to call a listen() method but I think this was either written for python or it is part of a library I do not know about.
My application is pretty short considering I am just focused on getting it hosted:
package com.marcuzzo.JDABot;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
public class Bot {
public static void main (String[] args) {
int port = Integer.parseInt(System.getenv("PORT"));
// String host = "0.0.0.0";
String token = "insert token here";
try {
JDA jda = JDABuilder.createDefault(token).build();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
I am not sure if there is a certain method in the JDA library I am using that would solve this problem but I have not found any so far.

Looks like your bot is not web app. You should use worker heroku configuration. Please check https://devcenter.heroku.com/articles/run-non-web-java-processes-on-heroku

Related

Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch java

I upload the .jar file of my bot for discord to heroku. Everything works as it should. And then the app breaks down and everything stops working.
Application Logs
heroku[web.1]: Starting process with command `java $JAVA_OPTS -jar target/DiscordBot-1.0-SNAPSHOT-jar-with-dependencies.jar -Dserver.port=43997`
app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
app[web.1]: [main] INFO net.dv8tion.jda.api.JDA - Login Successful!
app[web.1]: [JDA MainWS-ReadThread] INFO net.dv8tion.jda.internal.requests.WebSocketClient - Connected to WebSocket
app[web.1]: [JDA MainWS-ReadThread] INFO net.dv8tion.jda.api.JDA - Finished Loading!
heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
heroku[web.1]: Stopping process with SIGKILL
heroku[web.1]: Process exited with status 137
Procfile
web: java $JAVA_OPTS -jar target/DiscordBot-1.0-SNAPSHOT-jar-with-dependencies.jar -Dserver.port=$PORT
application.properties
server.port=${PORT:8080}
worker: java -jar target/DiscordBot-1.0-SNAPSHOT-jar-with-dependencies.jar
without server.port=${PORT:8080} in application.properties

Java web application not binding with Heroku $PORT

I have made a Java web application and trying to host it on Heroku with a Dockerfile, CMD as :
CMD ["java", "-Dserver.port=$PORT", "-jar", "/usr/local/lib/backend.jar", "--server.port=$PORT"]
And getting the logs as follows:
2022-05-06T06:53:33.599532+00:00 heroku[web.1]: Starting process with command `java -Dserver.port\=\27061 -jar /usr/local/lib/backend.jar --server.port\=\27061`
2022-05-06T06:53:35.445811+00:00 app[web.1]: 199 [main] INFO org.reflections.Reflections - Reflections took 179 ms to scan 1 urls, producing 4 keys and 22 values
2022-05-06T06:53:41.324114+00:00 app[web.1]: 6078 [main] INFO org.reflections.Reflections - Reflections took 58 ms to scan 1 urls, producing 3 keys and 16 values
2022-05-06T06:53:41.544513+00:00 app[web.1]: May 06, 2022 6:53:41 AM org.javawebstack.httpserver.HTTPServer start
2022-05-06T06:53:41.544514+00:00 app[web.1]: INFO: HTTP-Server started on port 1337
I am not getting able to understand that my argument is providing --server.port=27061 but still the HTTP server is starting on port 1337.
I have already seen all the related available answers on Stack Overflow but none works for me.
I am using javawebstack httpserver

Deploying to Heroku crash: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch

I get this error after deploying my springboot application in Heroku:
2019-12-12T19:09:35.340701+00:00 heroku[web.1]: State changed from starting to crashed
2019-12-12T19:09:35.088497+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
2019-12-12T19:09:35.088497+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-12-12T19:09:35.319755+00:00 heroku[web.1]: Process exited with status 137
2019-12-12T19:16:46.351647+00:00 heroku[web.1]: State changed from crashed to starting
2019-12-12T19:16:50.604492+00:00 heroku[web.1]: Starting process with command `java -Dserver.port=35960 $JAVA_OPTS -jar build/libs/*.jar`
So I tried to make a Procfile on the root folder of my project and this is the content:
Procfile:
web: java -Dserver.port=$PORT -jar build/libs/*.jar
I also added this line to my application.properties file.
application.properties:
server.port=${PORT:5000}
However, it's still not working.
The error above is still happening. How do I fix this? What else am I missing?
I'm using gradle, java11 and spring boot.

R14 & R10 in Heroku deploying Spring MVC application

I am trying to deploy an Spring MVC app through Codeship CI flow in a 1x dyno on heroku with embedded jetty (version 8).
Codeship flow works but in the deployment step R14 and R10 heroku errors appears.
I have tried in my local with identical java parameters and it is deployed fine in 15-20 seconds.
What could be the reason?
PROCFILE
web: java -Dserver.port=$PORT $JAVA_OPTS -jar target/dependency/jetty-runner.jar target/*.war
system.properties
java.runtime.version=1.7
HEROKU LOG
2014-09-06T16:12:07.070516+00:00 heroku[web.1]: Starting process with command `java -Dserver.port=17223 -Xmx384m -Xms384m -Xss512k -XX:+UseCompressedOops -jar target/dependency/jetty-runner.jar target/*.war`
2014-09-06T16:12:07.698033+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Djava.rmi.server.useCodebaseOnly=true -Djava.rmi.server.useCodebaseOnly=true
2014-09-06T16:12:08.350797+00:00 app[web.1]: 2014-09-06 16:12:08.349:INFO:omjr.Runner:Runner
2014-09-06T16:12:08.350934+00:00 app[web.1]: 2014-09-06 16:12:08.350:WARN:omjr.Runner:No tx manager found
2014-09-06T16:12:08.454514+00:00 app[web.1]: 2014-09-06 16:12:08.454:INFO:omjr.Runner:Deploying file:/app/target/MagmaInside221B.war # /
2014-09-06T16:12:08.477820+00:00 app[web.1]: 2014-09-06 16:12:08.477:INFO:oejs.Server:jetty-8.y.z-SNAPSHOT
2014-09-06T16:12:08.607664+00:00 app[web.1]: 2014-09-06 16:12:08.607:INFO:oejw.WebInfConfiguration:Extract jar:file:/app/target/MagmaInside221B.war!/ to /app/target/MagmaInside221B
2014-09-06T16:12:19.847416+00:00 app[web.1]: 2014-09-06 16:12:19.847:INFO:oejpw.PlusConfiguration:No Transaction manager found - if your webapp requires one, please configure one.
2014-09-06T16:12:23.593483+00:00 heroku[web.1]: source=web.1 dyno=heroku.29253714.85382d49-d1fa-4998-86f7-12cea60f83a4 sample#memory_total=319.66MB sample#memory_rss=234.84MB sample#memory_cache=84.83MB sample#memory_swap=0.00MB sample#memory_pgpgin=97083pages sample#memory_pgpgout=15249pages
2014-09-06T16:12:44.726949+00:00 heroku[web.1]: source=web.1 dyno=heroku.29253714.85382d49-d1fa-4998-86f7-12cea60f83a4 sample#memory_total=557.48MB sample#memory_rss=511.58MB sample#memory_cache=0.33MB sample#memory_swap=45.57MB sample#memory_pgpgin=199724pages sample#memory_pgpgout=68675pages
2014-09-06T16:12:44.727477+00:00 heroku[web.1]: Process running mem=557M(108.9%)
2014-09-06T16:12:44.727730+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2014-09-06T16:13:05.520637+00:00 heroku[web.1]: source=web.1 dyno=heroku.29253714.85382d49-d1fa-4998-86f7-12cea60f83a4 sample#load_avg_1m=1.20
2014-09-06T16:13:05.520729+00:00 heroku[web.1]: source=web.1 dyno=heroku.29253714.85382d49-d1fa-4998-86f7-12cea60f83a4 sample#memory_total=635.76MB sample#memory_rss=511.89MB sample#memory_cache=0.11MB sample#memory_swap=123.77MB sample#memory_pgpgin=250735pages sample#memory_pgpgout=119665pages
2014-09-06T16:13:05.521268+00:00 heroku[web.1]: Process running mem=635M(124.2%)
2014-09-06T16:13:05.521494+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2014-09-06T16:13:07.096312+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2014-09-06T16:13:07.096536+00:00 heroku[web.1]: Stopping process with SIGKILL
2014-09-06T16:13:07.998339+00:00 heroku[web.1]: Process exited with status 137
2014-09-06T16:13:08.009655+00:00 heroku[web.1]: State changed from starting to crashed
You're exceeding the Heroku memory limit for your configured dyno. This has nothing to do with how you deploy (i.e. this will also happen when you push from your local machine). As for solving this problem, you'd either need to upgrade to a more powerful dyno or reduce the memory footprint of your application.
Disclaimer, I'm working for Codeship. I talked to Antonio via our in app support tool and we solved the issue, but I wanted to provide a public answer as well.

Running Dropwizard app on Heroku: R10 failed to bind to $PORT

I was recently pointed in the direction of dropwizard and heroku for the relatively easy creation and deployment of restFUL webservices.
Having followed the getting started tutorial at http://dropwizard.readthedocs.org/en/latest/getting-started.html I soon had a simple Hello World service running on my localhost, no problems at all.
Moving onto trying to deploy this on Heroku I have hit an issue. On deploying the app to heroku, I get an error
2014-08-14T11:34:59.869067+00:00 heroku[web.1]: State changed from starting to crashed
2014-08-14T11:34:59.070364+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web
process failed to bind to $PORT within 60 seconds of launch
2014-08-14T11:34:59.070573+00:00 heroku[web.1]: Stopping process with SIGKILL
2014-08-14T11:34:59.857478+00:00 heroku[web.1]: Process exited with status 137
My Procfile looks like....
web java $JAVA_OPTS -D.http.port=$PORT -jar target/exampleMavenProject-0.0.1-SNAPSHOT.jar server hello-world.yml
Which is exactly the same as the command line code to run the app on the local host, with the exception of
$JAVA_OPTS -D.http.port=$PORT
$JAVA_OPTS is definied within the herkou app config variables; and from my understanding $PORT can't be overridden.
And the hello-world.yml doesn't have any extra configuration variables in it other than those required for the dropwizard example
template: Hello, %s!
defaultName: Stranger
Does anyone have any suggestions as to why this doesn't work?
Thanks.
Dropwizard 0.7.x has changed their server configurations; in particular, http.port does not work anymore.
Instead, you should be using server.connector.port for your procfile/.yml files. Here's an example:
Procfile
web: java $JAVA_OPTS -Ddw.server.connector.port=$PORT -jar target/pos-tagger-1.0-SNAPSHOT.jar server src/main/resources/POSTagger.yml
POSTagger.yml
server:
type: simple
applicationContextPath: /
adminContextPath: /admin
connector:
type: http
port: 8080
If you want to see a full, working heroku example using 0.7.x, check out: https://github.com/xinranxiao/POSTagger
Update for Dropwizard 1.0 with Gradle:
Procfile
web: java $JAVA_OPTS -Ddw.server.applicationConnectors[0].port='$PORT' -jar build/libs/yourJar-1.0-all.jar server config-production.yml
config-production.yml
server:
registerDefaultExceptionMappers: false
applicationConnectors:
- type: http
port: 8080

Categories

Resources