Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught exception causes failure to reconnect. #128

Open
phronmophobic opened this issue Jul 27, 2023 · 3 comments
Open

Uncaught exception causes failure to reconnect. #128

phronmophobic opened this issue Jul 27, 2023 · 3 comments
Labels
bug report Reported, but unconfirmed bugs.

Comments

@phronmophobic
Copy link

I have a discord bot that runs in the background for long periods of time that usually works great. Intermittently, I get a
WebSocketException in the logs (see log section). After that, the bot no longer appears online and doesn't receive messages. I have to shut everything down and restart the bot.

Version Information

  • Clojure Version: 1.11.1
  • Discljord Version: 1.3.1
  • OS bot is hosted on: Linux

To Reproduce

I don't have a consistent approach to reproducing the exception, but I think there might still be enough info to attempt a fix.

Expected behavior

The bot should continue trying to reconnect.

Logs

Jul 25, 2023 12:33:26 AM discljord.connections.impl invoke
INFO: Exiting the shard loop
Exception in thread "async-dispatch-10" java.util.concurrent.ExecutionException: org.eclipse.jetty.websocket.api.WebSocketException: Session closed
	at org.eclipse.jetty.util.FutureCallback.get(FutureCallback.java:123)
	at org.eclipse.jetty.util.FutureCallback.get(FutureCallback.java:30)
	at clojure.core$deref_future.invokeStatic(core.clj:2317)
	at clojure.core$deref.invokeStatic(core.clj:2337)
	at clojure.core$deref.invoke(core.clj:2323)
	at gniazdo.core$eval32382$fn__32383.invoke(core.clj:21)
	at gniazdo.core$eval32363$fn__32364$G__32354__32371.invoke(core.clj:17)
	at gniazdo.core$connect_with_client$reify__32474.send_msg(core.clj:138)
	at discljord.connections.impl$step_shard_BANG_$heartbeat_fn__33010.invoke(impl.clj:393)
	at discljord.connections.impl$step_shard_BANG_$fn__33161$state_machine__16821__auto____33188$fn__33190.invoke(impl.clj:438)
	at discljord.connections.impl$step_shard_BANG_$fn__33161$state_machine__16821__auto____33188.invoke(impl.clj:431)
	at clojure.core.async.impl.runtime$run_state_machine.invokeStatic(runtime.clj:62)
	at clojure.core.async.impl.runtime$run_state_machine.invoke(runtime.clj:61)
	at clojure.core.async.impl.runtime$run_state_machine_wrapped.invokeStatic(runtime.clj:66)
	at clojure.core.async.impl.runtime$run_state_machine_wrapped.invoke(runtime.clj:64)
	at clojure.core.async$ioc_alts_BANG_$fn__11707.invoke(async.clj:423)
	at clojure.core.async$do_alts$fn__11638$fn__11641.invoke(async.clj:290)
	at clojure.core.async.impl.channels.ManyToManyChannel$fn__11351$fn__11352.invoke(channels.clj:100)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at clojure.core.async.impl.concurrent$counted_thread_factory$reify__11220$fn__11221.invoke(concurrent.clj:29)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.eclipse.jetty.websocket.api.WebSocketException: Session closed
	at org.eclipse.jetty.websocket.common.WebSocketSession.outgoingFrame(WebSocketSession.java:350)
	at org.eclipse.jetty.websocket.common.WebSocketRemoteEndpoint.uncheckedSendFrame(WebSocketRemoteEndpoint.java:322)
	at org.eclipse.jetty.websocket.common.WebSocketRemoteEndpoint.sendAsyncFrame(WebSocketRemoteEndpoint.java:243)
	at org.eclipse.jetty.websocket.common.WebSocketRemoteEndpoint.sendStringByFuture(WebSocketRemoteEndpoint.java:419)
	at gniazdo.core$eval32382$fn__32383.invoke(core.clj:24)
	... 18 more

Additional context

  • I'm running the bot on a dinky server
  • The server is usually not doing much, but sometimes has a lot of work to do that might bog down the CPU and/or cause memory pressure on the JVM
@phronmophobic phronmophobic added the bug report Reported, but unconfirmed bugs. label Jul 27, 2023
@IGJoshua
Copy link
Collaborator

This looks to me like this is happening when Discord is shutting down the gateway server your bot is connected to. In that case I would expect discljord to attempt to reconnect, however I can attempt to reproduce this error with a mock discord server and see about fixing it.

Thanks for bringing it up!

If I'm right about what's caused the issue, I wouldn't expect this to be a frequent occurrence, but it is important to be aware of until it's fixed.

@phronmophobic
Copy link
Author

Very cool. Thanks for the project. It's been great.

The problem doesn't occur too much, but I think there's something about my server usage (eg. dinky server with intermittent CPU and Memory spikes) that makes it more likely.

@phronmophobic
Copy link
Author

My setup seems to be able to trigger the error every few days. Let me know if there's any helpful info I can collect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Reported, but unconfirmed bugs.
Projects
None yet
Development

No branches or pull requests

2 participants