After reviewing reports of my bot, ErisBot disappearing from a set amount of guilds, I've found that JDA will sometimes struggle to detect the socket being closed.
I'm assuming this only affects a timeout since it doesn't always happen but have not tested.
After around 10-20 minutes after the connection has died, it finally realizes and closes, thus attempting a reconnect.
I've reported it in the Discord and @Almighty-Alpaca found that there is no timeout set on the websocket. I got asked to open a Github issue to help track this so hello!
I checked the internal source of the websocket and didn't see the possibility to set a timeout except for the initial connection (default java socket timeout system).
In 3.x I'm going to be reinvestigating the heartbeat ack for forcing disconnect.
JDA 2 no longer has support along with everybody shifting off it. This shouldn't be a problem for JDA 3 considering it's been completely rewritten.
Closing.
Most helpful comment
I checked the internal source of the websocket and didn't see the possibility to set a timeout except for the initial connection (default java socket timeout system).
In 3.x I'm going to be reinvestigating the heartbeat ack for forcing disconnect.