KittehOrg/KittehIRCClientLib

RegistrationTimeout on reconnect using ClientConnectionEndedEvent

zachbr opened this issue · 1 comments

Expected behavior
I thought that by setting the IRC library to reconnect in ClientConnectionClosedEvent that it would reconnect to the IRC server and let me do IRC things.

Actual behavior
The IRC library attempts to reconnect however it does not succeed. It seems to try, and then it thinks it is connected for a short time, but looking at the IRCd logs reveals that it doesn't successfully reconnect. Instead, it appears to timeout during the reconnection. Eventually it appears to timeout and then it calls the event again where this cycle continues to repeat infinitely.

On the IRCd side of things, this message is the only hint I can see unfortunately
QuitUser: 742AAAAAL=742AAAAAL 'Registration timeout'

From the IRC library (the minimal case below):

18:32 [I] ERROR :Closing link: (TestBot@Host.lan) [Server shutting down]
Attempting reconnect 0
18:37 [I] :whatever.localhost.tld NOTICE * :*** Looking up your hostname...
18:37 [I] :whatever.localhost.tld NOTICE * :*** Found your hostname (Host.lan)
18:58 [I] ERROR :Closing link: (742AAAAAA@Host.lan) [Registration timeout]
Attempting reconnect 1
19:03 [I] :whatever.localhost.tld NOTICE * :*** Looking up your hostname...
19:03 [I] :whatever.localhost.tld NOTICE * :*** Found your hostname (Host.lan)
19:24 [I] ERROR :Closing link: (742AAAAAB@Host.lan) [Registration timeout]
Attempting reconnect 2
19:29 [I] :whatever.localhost.tld NOTICE * :*** Looking up your hostname...
19:29 [I] :whatever.localhost.tld NOTICE * :*** Found your hostname (Host.lan)

I have tested this with local test instances of UnrealIRCd and InspIRCd, both result in the same behavior.

Stacktrace
There is no stacktrace provided by the library. Behaviorally, It seems to believe it has reconnected and then it times out (?) and the ClientConnectionClosedEvent re-fires and the library attempts to reconnect again, looping infinitely.

To Reproduce
A minimal test case is provided below.

import net.engio.mbassy.listener.Handler;
import org.kitteh.irc.client.library.Client;
import org.kitteh.irc.client.library.event.connection.ClientConnectionClosedEvent;

import java.text.SimpleDateFormat;
import java.util.Date;

public class IrcTester {
    public static void main(String[] args) {
        new IrcTester();
    }

    private static final String IRC_HOSTNAME = "192.168.1.10";
    private static final int IRC_PORT = 6667;
    private static final String IRC_NICKNAME = "TestBot";

    private int attempts = 0;

    IrcTester() {
        SimpleDateFormat sdf = new SimpleDateFormat("mm:ss");
        Client irc = Client.builder()
                .server()
                .host(IRC_HOSTNAME)
                .port(IRC_PORT, Client.Builder.Server.SecurityType.INSECURE)
                .then()
                .nick(IRC_NICKNAME)
                .name(IRC_NICKNAME)
                .user(IRC_NICKNAME)
                .listeners()
                .input(line -> System.out.println(sdf.format(new Date()) + ' ' + "[I] " + line))
                .output(line -> System.out.println(sdf.format(new Date()) + ' ' + "[O] " + line))
                .exception(Throwable::printStackTrace)
                .then()
                .buildAndConnect();

        irc.setExceptionListener(Throwable::printStackTrace);
        irc.getEventManager().registerEventListener(this);

        irc.addChannel("#test");
        irc.sendMessage("#test", "Hello world!");
    }

    @Handler
    public void onClientDisconnect(ClientConnectionClosedEvent event) {
        event.setAttemptReconnect(true);
        System.out.println("Attempting reconnect " + attempts++);
    }
}

Version information

  • OS: Windows 10 20H2 and Ubuntu 20.04.2 LTS
  • JVM: openjdk version "1.8.0_282"and openjdk 11.0.10 2021-01-19
  • KICL version: 7.4.0

Additional context
Anything else? Thank you for KICL :D

This was fixed with 127dfa9
Thanks again, pleasure working with you mbax.