jagrosh / MusicBot

🎶 A Discord music bot that's easy to set up and run yourself!
https://jmusicbot.com
Apache License 2.0
5.33k stars 2.55k forks source link

[Bug Report] No handling for no internet connection #1303

Open LachlanPond opened 1 year ago

LachlanPond commented 1 year ago

Bug Description

When running the bot without an internet connection, the JDA connection attempt will fail without catching the exception and doing a proper system exit. When a server (physical PC) running the bot restarts, if there is no internet connection when the system starts, the bot will fail without crashing and therefore cannot be restarted automatically.

`[06:02:09] [ERROR] [Requester]: DNS resolution failed: discord.com: Name or service not known Exception in thread "main" net.dv8tion.jda.api.exceptions.ErrorResponseException: -1: java.net.UnknownHostException at net.dv8tion.jda.internal.requests.RestActionImpl.complete(RestActionImpl.java:227) at net.dv8tion.jda.api.requests.RestAction.complete(RestAction.java:633) at net.dv8tion.jda.api.utils.SessionControllerAdapter.getGateway(SessionControllerAdapter.java:86) at net.dv8tion.jda.internal.JDAImpl.getGateway(JDAImpl.java:318) at net.dv8tion.jda.internal.JDAImpl.login(JDAImpl.java:276) at net.dv8tion.jda.internal.JDAImpl.login(JDAImpl.java:268) at net.dv8tion.jda.api.JDABuilder.build(JDABuilder.java:1874) at com.jagrosh.jmusicbot.JMusicBot.startBot(JMusicBot.java:187) at com.jagrosh.jmusicbot.JMusicBot.main(JMusicBot.java:65) Caused by: java.net.UnknownHostException: discord.com: Name or service not known

...

Caused by: net.dv8tion.jda.api.exceptions.ContextException at net.dv8tion.jda.api.exceptions.ContextException.here(ContextException.java:54) at net.dv8tion.jda.api.requests.Request.(Request.java:71) at net.dv8tion.jda.api.requests.RestFuture.(RestFuture.java:36) at net.dv8tion.jda.internal.requests.RestActionImpl.submit(RestActionImpl.java:209) at net.dv8tion.jda.internal.requests.RestActionImpl.complete(RestActionImpl.java:219) at net.dv8tion.jda.api.requests.RestAction.complete(RestAction.java:633) at net.dv8tion.jda.api.utils.SessionControllerAdapter.getGateway(SessionControllerAdapter.java:86) at net.dv8tion.jda.internal.JDAImpl.getGateway(JDAImpl.java:318) at net.dv8tion.jda.internal.JDAImpl.login(JDAImpl.java:276) at net.dv8tion.jda.internal.JDAImpl.login(JDAImpl.java:268) at net.dv8tion.jda.api.JDABuilder.build(JDABuilder.java:1874) at com.jagrosh.jmusicbot.JMusicBot.startBot(JMusicBot.java:187) at com.jagrosh.jmusicbot.JMusicBot.main(JMusicBot.java:65)`

Steps to Reproduce

  1. Start the bot without an internet connection

Expected Result

I expect the bot to system exit if launched with no internet connection

Debug Output

OS: Debian GNU/Linux 11 (bullseye) JMusicBot: 0.3.8

Additional Info

No response

Checklist

Nicolas-GE commented 1 year ago

+1, i've been having internet issues recently and having to restart it after i'm connected again is annoying