KittehOrg / KittehIRCClientLib

An IRC client library in Java
https://kitteh.dev/kicl/
MIT License
146 stars 34 forks source link

Client doesn't reconnect to twitch after a network failure #285

Closed onoderis closed 4 years ago

onoderis commented 4 years ago

Expected behavior Keep receiving ChannelMessageEvent and other events after a reconnect.

Actual behavior The client keeps connecting and disconnection again and again after a network failure.

To Reproduce

  1. Run the following code (put your login and password).
  2. Disable and enable your network interface.
  3. See the following events:
    16:39:12.249: ClientConnectionEstablishedEvent
    16:39:42.456: ClientConnectionClosedEvent
    16:39:47.729: ClientConnectionEstablishedEvent
    16:40:07.252: ClientReceiveCommandEvent
    16:40:17.935: ClientConnectionClosedEvent
    16:40:23.145: ClientConnectionEstablishedEvent
    16:40:53.351: ClientConnectionClosedEvent

Version information

Additional context I would really like to use this library in my project but an automatic reconnect is the feature that I need the most right now and it doesn't work in my case 😔. Thanks for the library anyway.

mbax commented 4 years ago

I regretfully was unable to attend to this issue until now. I hope you have found success in your project! :)

The issue appears to have been a problematic interaction between KICL accidentally adding more CAP LS/USER/NICK lines to the queue each time it attempted to reconnect, and servers not sending all responses at once. This gave interesting logs like this ([I] for incoming messages to the client, [O] for outgoing):

06:06 [O] CAP LS 302
06:06 [O] USER Kitteh 8 * :KICL 7.3.0-SNAPSHOT - kitteh.org
06:06 [O] NICK KittehTest
06:06 [O] CAP LS 302
06:06 [O] USER Kitteh 8 * :KICL 7.3.0-SNAPSHOT - kitteh.org
06:06 [O] NICK KittehTest
06:06 [O] CAP LS 302
06:06 [O] USER Kitteh 8 * :KICL 7.3.0-SNAPSHOT - kitteh.org
06:06 [O] NICK KittehTest
06:06 [O] CAP LS 302
06:06 [O] USER Kitteh 8 * :KICL 7.3.0-SNAPSHOT - kitteh.org
06:06 [O] NICK KittehTest
06:06 [O] CAP LS 302
06:06 [O] USER Kitteh 8 * :KICL 7.3.0-SNAPSHOT - kitteh.org
06:06 [O] NICK KittehTest
06:06 [O] CAP LS 302
06:06 [O] USER Kitteh 8 * :KICL 7.3.0-SNAPSHOT - kitteh.org
06:06 [O] NICK KittehTest
06:06 [O] CAP LS 302
06:06 [O] USER Kitteh 8 * :KICL 7.3.0-SNAPSHOT - kitteh.org
06:06 [O] NICK KittehTest
06:06 [O] CAP LS 302
06:06 [O] USER Kitteh 8 * :KICL 7.3.0-SNAPSHOT - kitteh.org
06:06 [O] NICK KittehTest
06:06 [O] CAP LS 302
06:06 [O] USER Kitteh 8 * :KICL 7.3.0-SNAPSHOT - kitteh.org
06:06 [O] NICK KittehTest
06:06 [I] :irc.example.com NOTICE * :*** Looking up your hostname...
06:06 [I] :irc.example.com NOTICE * :*** Checking Ident
06:06 [I] :irc.example.com NOTICE * :*** Found your hostname
06:11 [I] :irc.example.com NOTICE * :*** No Ident response
06:11 [I] :irc.example.com CAP * LS :account-notify away-notify cap-notify chghost extended-join multi-prefix sasl tls userhost-in-names
06:11 [I] :irc.example.com 433 * KittehTest :Nickname is already in use.
06:11 [I] :irc.example.com CAP * LS :account-notify away-notify cap-notify chghost extended-join multi-prefix sasl tls userhost-in-names
06:11 [O] CAP REQ :userhost-in-names chghost multi-prefix extended-join account-notify away-notify
06:11 [O] NICK KittehTest`
06:11 [O] CAP REQ :userhost-in-names chghost multi-prefix extended-join account-notify away-notify
06:11 [I] :irc.example.com 433 * KittehTest :Nickname is already in use.
06:11 [O] NICK KittehTest``
06:12 [I] :irc.example.com CAP * LS :account-notify away-notify cap-notify chghost extended-join multi-prefix sasl tls userhost-in-names
06:12 [O] CAP REQ :userhost-in-names chghost multi-prefix extended-join account-notify away-notify
06:14 [I] :irc.example.com 433 * KittehTest :Nickname is already in use.
06:14 [O] NICK KittehTest```
06:15 [I] :irc.example.com CAP * LS :account-notify away-notify cap-notify chghost extended-join multi-prefix sasl tls userhost-in-names
06:15 [O] CAP REQ :userhost-in-names chghost multi-prefix extended-join account-notify away-notify
06:17 [I] :irc.example.com 433 * KittehTest :Nickname is already in use.
06:17 [O] NICK KittehTest````
06:18 [I] :irc.example.com CAP * LS :account-notify away-notify cap-notify chghost extended-join multi-prefix sasl tls userhost-in-names
06:18 [O] CAP REQ :userhost-in-names chghost multi-prefix extended-join account-notify away-notify
06:20 [I] :irc.example.com 433 * KittehTest :Nickname is already in use.
06:20 [O] NICK KittehTest`````
06:21 [I] :irc.example.com CAP * LS :account-notify away-notify cap-notify chghost extended-join multi-prefix sasl tls userhost-in-names
06:21 [O] CAP REQ :userhost-in-names chghost multi-prefix extended-join account-notify away-notify
06:23 [I] :irc.example.com 433 * KittehTest :Nickname is already in use.
06:23 [O] NICK KittehTest``````
06:24 [I] :irc.example.com CAP * LS :account-notify away-notify cap-notify chghost extended-join multi-prefix sasl tls userhost-in-names
06:24 [O] CAP REQ :userhost-in-names chghost multi-prefix extended-join account-notify away-notify
06:26 [I] :irc.example.com 433 * KittehTest :Nickname is already in use.
06:26 [O] NICK KittehTest```````
06:27 [I] :irc.example.com CAP * LS :account-notify away-notify cap-notify chghost extended-join multi-prefix sasl tls userhost-in-names
06:27 [O] CAP REQ :userhost-in-names chghost multi-prefix extended-join account-notify away-notify
06:29 [I] :irc.example.com 433 * KittehTest :Nickname is already in use.
06:29 [O] NICK KittehTest````````
06:30 [I] :irc.example.com CAP * LS :account-notify away-notify cap-notify chghost extended-join multi-prefix sasl tls userhost-in-names
06:30 [O] CAP REQ :userhost-in-names chghost multi-prefix extended-join account-notify away-notify

This would then slowly continue until timeout or something else goofy happening.

I suspect in situations where disconnection had been long enough to open up the nickname, there would be a similar issue with the ACK not coming and thus just timing out. Both of these situations are easily resolved by just not re-queuing.

This should be resolved in the latest commit to the next branch, https://github.com/KittehOrg/KittehIRCClientLib/commit/a456426481cdb66b0e7a5ef249284f753bba1874 , and will be in the next release.

TheMaverickProgrammer commented 2 years ago

Which release was this referring to? 8.0.0 on maven still has this issue. If I disconnect and reconnect, more often than not, I'll get a duplicate nickname error.

mbax commented 2 years ago

@TheMaverickProgrammer wrote

Which release was this referring to? 8.0.0 on maven still has this issue. If I disconnect and reconnect, more often than not, I'll get a duplicate nickname error.

This was fixed for the 7.3.0 release, and would thus also be fixed in 7.4.0 and 8.0.0

Can you open a new issue with a demo log of all incoming and outgoing like what I did above? In mine it clearly shows a ton of replies to a duplicated NICK that was all sent before the attempts to change nick.

TheMaverickProgrammer commented 2 years ago

The mistake was on my end. I had a zombie connection (a valid connection I never shutdown)