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

Report-kinda | withReconnects() throws exception #51

Closed
iGoodie opened this issue Jun 16, 2016 · 9 comments
Closed

Report-kinda | withReconnects() throws exception #51

iGoodie opened this issue Jun 16, 2016 · 9 comments
Labels
wontfix Maintainers have decided to not fix this issue

Comments

@iGoodie
Copy link

iGoodie commented Jun 16, 2016

Hash: 82c2bb4
After I made my bot login. I disabled my network adapter for test purposes and that happened on the console:

[main] INFO sx.blah.discord.Discord4J - Discord4J v2.5.0-SNAPSHOT
[main] INFO sx.blah.discord.Discord4J - A Java binding for the unofficial Discord API, forked from https://github.com/nerd/Discord4J. Copyright (c) 2016, Licensed under GNU GPLv2
[AWT-EventQueue-0] INFO org.eclipse.jetty.util.log - Logging initialized @3791ms
[WebSocketClient@682010040-26] INFO sx.blah.discord.Discord4J - Connected to the Discord Websocket v5
[Request Builder Async Executor] INFO sx.blah.discord.Discord4J - Connected to 1 guilds.
[WebSocketClient@682010040-30] INFO sx.blah.discord.Discord4J - Attempting to reconnect...
[Websocket Reconnect Timer] ERROR sx.blah.discord.Discord4J - Reconnect attempt timed out after 10 seconds
[WebSocketClient@682010040-32] ERROR sx.blah.discord.Discord4J - Websocket error, disconnecting...
java.nio.channels.UnresolvedAddressException
    at sun.nio.ch.Net.checkAddress(Net.java:121)
    at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:617)
    at org.eclipse.jetty.websocket.client.io.ConnectionManager$PhysicalConnect.run(ConnectionManager.java:70)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
    at java.lang.Thread.run(Thread.java:745)

Tried to reconnect once, then threw exception.

@theIglooo
Copy link
Member

Isn't that expected? It can't resolve because there's no internet connection?

@iGoodie
Copy link
Author

iGoodie commented Jun 17, 2016

@theIglooo shouldn't it keep trying to reconnect instead of throwing exception, just for such case? At least isn't that what withReconnects() method for, preventing any manual reconnecting situation such as losing connection for a sec?

@ghost
Copy link

ghost commented Jun 17, 2016

There is no way the bot can even attempt to connect to discord if it can't lookup the IP address to connect to. Simple as that.

If it was going to keep on reconnecting (assuming the IP address is cached), you will eventually get a Connection refused or Connection timed out IOException.

@iGoodie
Copy link
Author

iGoodie commented Jun 17, 2016

@LolDatSec at least it should run the same code chunk to prevent such case, instead of terminating the process.
EDIT: Also I can't handle that exception which gives me no other option than manually reconnecting. The reason I can't handle it because it is threw in the lib codes.

@theIglooo
Copy link
Member

@iGoodie That's not why you can't handle it, it's an unchecked exception. If that was case then you wouldn't be catching MissingPermissionsExceptions or any of those. I don't know what you want it to do, even if it hopelessly tries to reconnect it'll stop after the 3rd(?).

@austinv11 austinv11 added the wontfix Maintainers have decided to not fix this issue label Jun 18, 2016
@austinv11
Copy link
Member

When the lib encounters an error with the websocket, it is unrecoverable. You can try to login again later but a websocket error like this means that there is no use in trying to reconnect because the websocket wouldn't work correctly. And this is not something I can fix as all that code is internally Jetty Websocket's. And as previously mentioned, you have no internet connection so there's no use in reconnecting.

@austinv11
Copy link
Member

austinv11 commented Jun 18, 2016

Additionally, reconnects are mostly meant to reconnect to Discord after getting disconnected for some reason by Discord as Discord's cloudflare likes to randomly disconnect clients.

@iGoodie
Copy link
Author

iGoodie commented Jun 23, 2016

Ummm but imagine that I lost my connection just for a second, then there is an use in trying to reconnect. Just like any application (like Discord) reconnects after you got your connection back.

@austinv11
Copy link
Member

Yes, but it did try to reconnect. Additionally, you can still handle this yourself if the auto reconnect feature failed by listening for the DiscordDisconnectedEvent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix Maintainers have decided to not fix this issue
Projects
None yet
Development

No branches or pull requests

3 participants