kerozene / cahbot

Cards Against Humanity IRC bot
6 stars 2 forks source link

Disconnecting after sending pong #7

Closed ellisgl closed 4 years ago

ellisgl commented 7 years ago

6 Oct 23:16:34 - Sending irc NICK/USER 6 Oct 23:16:36 - SEND: CAP LS 302 6 Oct 23:16:36 - Capabilities supported: userhost-in-names multi-prefix away-notify account-notify tls 6 Oct 23:16:36 - CAP LS: not requesting unsupported capabilities: extended-join 6 Oct 23:16:38 - SEND: NICK cah-bot 6 Oct 23:16:40 - SEND: USER cah 8 * CAHbot 6 Oct 23:16:42 - SEND: CAP REQ :account-notify sasl 6 Oct 23:16:44 - SEND: PONG 6E3CECD8 6 Oct 23:17:04 - Unhandled message: { command: 'ERROR', rawCommand: 'ERROR', commandType: 'normal', args: [ 'Closing Link: cah-bot[x.x.x.x](Registration Timeout)' ] } 6 Oct 23:17:04 - Connection got "end" event 6 Oct 23:17:04 - Connection got "close" event 6 Oct 23:17:04 - Disconnected: reconnecting 6 Oct 23:17:04 - Waiting 2000ms before retrying

Jdbye commented 7 years ago

I have a similar issue.

n > Cards Against Humanity IRC bot 18 Apr 23:11:57 - Configuration loaded. 18 Apr 23:11:57 - Connecting to 127.0.0.1 as cah2... 18 Apr 23:11:57 - Sending irc NICK/USER 18 Apr 23:11:57 - Loaded 0 users 18 Apr 23:11:57 - User storage: 0 keys loaded 18 Apr 23:11:58 - Card storage: 21 keys found 18 Apr 23:11:58 - Enabled deck CAHBS: 90 questions 458 answers 18 Apr 23:11:58 - Enabled deck CAHE1: 20 questions 80 answers 18 Apr 23:11:58 - Enabled deck CAHE2: 25 questions 75 answers 18 Apr 23:11:58 - Enabled deck CAHE3: 25 questions 75 answers 18 Apr 23:11:58 - Enabled deck CAHE4: 30 questions 70 answers 18 Apr 23:11:58 - Enabled deck EU6CJ: 25 questions 75 answers 18 Apr 23:11:58 - Enabled deck PEU3Q: 25 questions 75 answers 18 Apr 23:11:58 - Enabled deck CWNUY: 6 questions 24 answers 18 Apr 23:11:58 - Enabled deck XMAS1: 7 questions 23 answers 18 Apr 23:11:58 - Enabled deck XVMCS: 8 questions 22 answers 18 Apr 23:11:58 - Enabled deck CANCK: 9 questions 27 answers 18 Apr 23:11:58 - Enabled deck 4MCMT: 22 questions 89 answers 18 Apr 23:11:58 - Enabled deck CYAFZ: 13 questions 107 answers 18 Apr 23:11:58 - Enabled deck GAWR5: 127 questions 556 answers 18 Apr 23:11:58 - Enabled deck XMJP5: 18 questions 49 answers 18 Apr 23:11:58 - Enabled deck 2HJMW: 46 questions 88 answers 18 Apr 23:11:58 - Enabled deck 74JJ5: 54 questions 170 answers 18 Apr 23:11:58 - Enabled deck XQ8X2: 250 questions 611 answers 18 Apr 23:11:58 - Enabled deck MWCE5: 161 questions 400 answers 18 Apr 23:11:58 - Enabled deck TWEUQ: 16 questions 19 answers 18 Apr 23:11:58 - Enabled deck BVPNZ: 162 questions 423 answers 18 Apr 23:11:59 - SEND: CAP LS 302 18 Apr 23:12:00 - Capabilities supported: multi-prefix sasl tls userhost-in-names 18 Apr 23:12:00 - CAP LS: not requesting unsupported capabilities: account-notify, extended-join 18 Apr 23:12:01 - SEND: NICK cah2 18 Apr 23:12:03 - SEND: USER cah 8 * :CAH Bot 18 Apr 23:12:08 - Unhandled message: { command: 'ERROR', rawCommand: 'ERROR', commandType: 'normal', args: [ 'Closing link: (cah@me.jdbye.com) [Registration timeout]' ] } n >

It seems to be sending NICK and USER to the server fine, but never receives a reply. Which is weird, because when I connect to the IRC server manually with putty and send the same exact NICK/USER commands, it connects fine. It seems to be related to the CAP LS 302 command, as I can't connect with a raw socket if I add that command, but without it, it works fine.

ellisgl commented 7 years ago

IIRC - if you run WireShark, I think the reply does come in - but isn't see by the script. Something else I've noticed is that Node-IRC would randomly disconnect in another project of mine - Read failure I think. I ended up changing to https://github.com/kiwiirc/irc-framework on my own projects. Haven't had a disconnect and also works well in windows (I only use windows for development).

Jdbye commented 7 years ago

This seems to be the problem. "If a client issues an LS subcommand, registration must be suspended until an END subcommand is received. If no capabilities are available, an empty parameter must be sent." From: http://ircv3.net/specs/core/capability-negotiation-3.1.html According to the code it seems to wait for an ACK before sending CAP END, but that ACK never occurs.

ellisgl commented 7 years ago

Oh yeah, I forgot he made a fork of Node_IRC for IRC_v3 stuff on this project. Well the server I connect to isn't IRCv3 and there's some issues with tracking names.

Jdbye commented 7 years ago

Editing this part of the code in node_modules/irc/lib/irc.js: if (unsupportedCapabilities.length && self.opt.debug) { util.log('CAP LS: not requesting unsupported capabilities: ' + unsupportedCapabilities.join(', ')); self.send('CAP', 'END'); self.emit('cap-end'); } Adding the self.send and self.emit resulted in it connecting to the IRC server correctly, although it did show a "Caught exception: TypeError: Cannot read property 'split' of undefined" error.

kerozene commented 7 years ago

@Jdbye if you're up for submitting a PR to https://github.com/kerozene/node-irc I'll be happy to review it. I don't have a non-atheme server to test on though so I don't have a way to track down that exception.

ellisgl commented 7 years ago

I ended up creating a complete fork teeli/irc-cah: https://github.com/ellisgl/node-irc-cah