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

Reconnection fails because of nick modification #168

Closed
aaronj1335 opened this issue May 14, 2013 · 2 comments
Closed

Reconnection fails because of nick modification #168

aaronj1335 opened this issue May 14, 2013 · 2 comments

Comments

@aaronj1335
Copy link

My IRC bot is unable to reconnect to my channel because it's invite only, and
when it tries to reconnect after a network failure node-irc changes the
nickname. Here's the log, notice when it changes the nick from fallbot to
fallbot1:

13 May 12:36:06 - Unhandled message: { command: 'ERROR',
  rawCommand: 'ERROR',
  commandType: 'normal',
  args: [ 'Closing Link: rrcs-108-178-74-64.sw.biz.rr.com (Ping timeout: 255 seconds)' ] }
13 May 12:36:06 - Connection got "close" event
13 May 12:36:06 - Disconnected: reconnecting
13 May 12:36:06 - Waiting 2000ms before retrying
13 May 12:36:06 - Connection got "end" event
13 May 12:36:06 - SEND: PONG zelazny.freenode.net
13 May 12:36:09 - Sending irc NICK/USER
13 May 12:36:09 - SEND: NICK fallbot
13 May 12:36:10 - SEND: USER nodebot 8 * :nodeJS IRC client
13 May 12:36:16 - SEND: NICK fallbot1
13 May 12:36:17 - Unhandled message: { prefix: 'leguin.freenode.net',
  server: 'leguin.freenode.net',
  command: 'rpl_luserunknown',
  rawCommand: '253',
  commandType: 'reply',
  args: [ 'fallbot1', '21', 'unknown connection(s)' ] }
13 May 12:36:17 - MODE:fallbot1 sets mode: +Zi

I think that after reconnection, node-irc gets an err_nicknameinuse command
and ends up here:

case "err_nicknameinuse":
    if ( typeof(self.opt.nickMod) == 'undefined' )
        self.opt.nickMod = 0;
    self.opt.nickMod++;
    self.send("NICK", self.opt.nick + self.opt.nickMod);
    self.nick = self.opt.nick + self.opt.nickMod;
    break;

Which makes sense, node-irc is making it's best effort to connect. But I don't
see how the err_nicknameinuse could be happening, since I'm fairly certain
that no one is logging into freenode and squatting on the fallbot handle in
that sub-second window (this isn't a one-time thing, it happens somewhat
regularly).

I suspect that my bot is detecting that it is not connected to freenode before
freenode notices. So when the bot tries to reconnect, freenode says the nick is
still in use.

Is there a way to prevent this? Can my bot fix this by handling that 'ERROR'
command? Or is this something that node-irc should handle?

@sigmatht
Copy link

This is something you would need to do, as your problem is server specific. The problem though is that your old client hasn't pinged out yet. When the network sends you the next PING request and that client fails to send back PONG, then the nickname will become available.

Only thing I could recommend doing would be to make sure you register the nick with the nickserv and then use the nickserv ghost command when you get

you should add something like client.send("nickserv", "ghost fallbot password")

@aaronj1335
Copy link
Author

@sigmatht cool, thanks for the recommendation. i think this is going to take some more debugging on my part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants