Heroku java app won't stay online for more than 90 seconds

Viewed 83

I have been trying to get my discord bot (jda/gradle) online on heroku for quite some time now, the only thing that works for me is using a .jar file to get my bot online, but unfortunately it goes offline after 90 seconds, and the heroku logs give this:

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

here is my build.gradle:

    plugins {
    id 'java'
    id 'application'
    id 'com.github.johnrengelman.shadow' version '7.0.0'
}

mainClassName = 'com.xlol.testbot.TestBot'

group 'com.xlol'
version '1.0'

sourceCompatibility = 16

repositories {
    mavenCentral()
    jcenter()
    maven {
        name 'm2-dv8tion'
        url 'https://m2.dv8tion.net/releases'
    }
}

task stage(dependsOn: ['build', 'clean'])
build.mustRunAfter clean

dependencies {
    implementation group: 'me.duncte123', name: 'botCommons', version: '1.0.45'

    implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
    implementation 'net.dv8tion:JDA:4.3.0_324'
    implementation 'io.github.cdimascio:java-dotenv:5.1.1'
    implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
}

compileJava.options.encoding = 'UTF-8'

my Procfile:

web: java $JAVA_OPTS -jar build/libs/HerokuTestBot-1.0-all.jar -Dserver.port=$PORT $JAR_OPTS

my system.properties:

java.runtime.version=16
server.port=${PORT:8080}

if you need anything else just ask for it, I have been trying to fix this issue for about 3 days now, any help would be appreciated, thanks in advance!

1 Answers

For people who want the answer (Credits to @Chris), this happened due to Heroku not being able to find a web application on the port "$PORT" (Variable by Heroku). This hosting requires a web port or application to access it through the website link.

However, in all cases. People will recommend you to use a VPS, or a hosting that supports Java hosting. (Example being: A host that hosts minecraft servers, because Minecraft runs on Java. || A host that supports Discord Bot Hosting in multiple languages, from NodeJS to Java)

Related