R14 & R10 in Heroku deploying Spring MVC application - java

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.

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

Spring Boot app in Docker receives: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

I have a Spring Boot app in Docker that runs on Heroku.
Recently, after updating Tomcat to 10.1.0-M10, I started getting this error:
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within
60 seconds of launch
The immediate thought of downgrading to lower versions doesn't work due to vulnerabilities in the earlier versions. I have checked possible causes and found Tomcat binding port issue.
I cannot set up fixed config for different ports as I am deploying to Heroku and dependent on their random ports.
My Dockerfile:
FROM azul/zulu-openjdk-alpine:11
ENV PORT=$PORT
COPY /target/app.jar /app.jar
CMD java -Xms256m -Xmx512m \
-Dlog4j2.formatMsgNoLookups=true \
-Djava.security.egd=file:/dev/./urandom \
-Dserver.port=$PORT \
-jar /app.jar
What is the way to solve it? Is there anything I am missing?
UPDATE:
There are more logs from Heroku:
Feb 22 12:50:16 integration-test app/web.1 2022-02-22 20:50:16.057 [main] INFO c.g.s.z.ApplicationKt - Started ApplicationKt in 8.09 seconds (JVM running for 9.062)
Feb 22 12:50:16 integration-test app/web.1 2022-02-22 20:50:16.060 [main] DEBUG o.s.b.a.ApplicationAvailabilityBean - Application availability state LivenessState changed to CORRECT
Feb 22 12:50:16 integration-test app/web.1 2022-02-22 20:50:16.063 [main] DEBUG o.s.b.a.ApplicationAvailabilityBean - Application availability state ReadinessState changed to ACCEPTING_TRAFFIC
Feb 22 12:51:06 integration-test heroku/web.1 Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
I found a solution that wasn't perfect but seemed to work for me.
Downgraded Spring Boot from 2.6.3 to 2.6.1
Downgraded Tomcat from 10.X.X to 9.X.X
Removed dev tools dependencies
I think the two latest did the magic. Dev tools stopped asking for an extra port in the test/prod environment. Tomcat bound the port in the version 9.X.X but not in 10.X.X.
Even though I found the solution, I don't know why it behaved like this, and it isn't perfect security-wise.
from the error message it seems that $PORT is not resolved to any environment variable.
deploying to heroku you must use .env file to define env vars (you can't use docker run -e PORT=1234) see documentation
When you use heroku locally, you can set config vars in a .env file. When heroku local is run .env is read and each name/value pair is set in the environment. You can use this same .env file when using Docker: docker run -p 5000:5000 --env-file .env <image-name>

Heroku Java application timing out after 90 seconds

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

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.

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