reactiflux / discord-irc

Connects Discord and IRC channels by sending messages back and forth.
MIT License
1.2k stars 293 forks source link

Bot randomly disconnects from Discord and doesn't reconnect. #159

Closed deathspawn closed 7 years ago

deathspawn commented 7 years ago

I'm not sure why it disconnects as there are no logs. The only way I can get it to reconnect is to restart the bot. It will remain on IRC and somehow still relay messages from IRC to Discord. On the Discord side, it shows up as offline and relays nothing from Discord to IRC.

StrikerMan780 commented 7 years ago

I can confirm. Restarting the bot will usually make it connect again, but it's still not perfect.

pseiler commented 7 years ago

I can confirm it too.

jamuwu commented 7 years ago

Happens to me too often ;-;

Paril commented 7 years ago

Happens here as well.

ekmartin commented 7 years ago

discord-irc doesn't really handle the connection to Discord, it uses discord.js for that (which also is supposed to support reconnecting upon disconnects).

There was a recent reconnect pull request though, which hasn't been released yet: https://github.com/hydrabolt/discord.js/pull/952 I'll update discord-irc to the latest version as soon as it releases.

In the meantime I've added loggers for the warn and debug Discord events, to help debug why it disconnects. This is released in version 2.1.6 of discord-irc. debug events are only enabled in development, which is signified by setting the environment variable NODE_ENV to development. Example: NODE_ENV=development discord-irc --config config.json.

lanato commented 7 years ago

Looks like the bug is still present in discord.js, multiple bot devs have reported problems with their bots not always reconnecting to discord. See hydrabolt/discord.js#965

lanato commented 7 years ago

Discord.js 11 is out. Unfortunately it seems to introduce some breaking changes: ( https://discord.js.org/#/docs/main/stable/general/updating )

/srv/discord-irc/node_modules/discord.js/src/util/Collection.js:151
      if (propOrFn === 'id') throw new RangeError('Don\'t use .find() with IDs. Instead, use .get(id).');
                             ^

RangeError: Don't use .find() with IDs. Instead, use .get(id).
    at Collection.find (/srv/discord-irc/node_modules/discord.js/src/util/Collection.js:151:36)
    at Function.getDiscordNicknameOnServer (/srv/discord-irc/dist/bot.js:133:39)
    at Bot.sendToIRC (/srv/discord-irc/dist/bot.js:167:28)
    at Client.discord.on.message (/srv/discord-irc/dist/bot.js:108:12)
    at emitOne (events.js:96:13)
    at Client.emit (events.js:188:7)
    at MessageCreateHandler.handle (/srv/discord-irc/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
    at WebSocketPacketManager.handle (/srv/discord-irc/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:120:65)
    at WebSocketManager.eventMessage (/srv/discord-irc/node_modules/discord.js/src/client/websocket/WebSocketManager.js:273:31)
    at WebSocketClient.internalOnMessage (/srv/discord-irc/node_modules/uws/uws.js:89:17)
ekmartin commented 7 years ago

@altyr I fixed the breaking changes and released a new version (2.1.7). Feel free to give it a try.

ekmartin commented 7 years ago

I'm gonna try closing this, since discord.js closed the upstream issue as fixed. Let me know if it still persists with 2.1.7 and I'll reopen.

StrikerMan780 commented 7 years ago

Gonna put it on NPM? Still 2.1.5 when I type discord-irc --version.

Also, typing npm remove -g discord-irc leaves the binary behind... So I deleted it. Now, when trying to install, nothing ends up installing.

striker@smavks:~$ sudo npm install -g discord-irc
/usr/bin/discord-irc -> /usr/lib/node_modules/discord-irc/dist/index.js

> iconv@2.2.1 install /usr/lib/node_modules/discord-irc/node_modules/iconv
> node-gyp rebuild

make: Entering directory '/usr/lib/node_modules/discord-irc/node_modules/iconv/build'
  CXX(target) Release/obj.target/iconv/src/binding.o
  CC(target) Release/obj.target/iconv/deps/libiconv/lib/iconv.o
  SOLINK_MODULE(target) Release/obj.target/iconv.node
  COPY Release/iconv.node
make: Leaving directory '/usr/lib/node_modules/discord-irc/node_modules/iconv/build'

> node-icu-charset-detector@0.2.0 install /usr/lib/node_modules/discord-irc/node_modules/node-icu-charset-de
tector
> node-gyp rebuild

make: Entering directory '/usr/lib/node_modules/discord-irc/node_modules/node-icu-charset-detector/build'
  CXX(target) Release/obj.target/node-icu-charset-detector/node-icu-charset-detector.o
  SOLINK_MODULE(target) Release/obj.target/node-icu-charset-detector.node
  COPY Release/node-icu-charset-detector.node
make: Leaving directory '/usr/lib/node_modules/discord-irc/node_modules/node-icu-charset-detector/build'
/usr/lib
└─┬ discord-irc@2.1.7 
  ├── check-env@1.2.0 
  ├─┬ commander@2.9.0 
  │ └── graceful-readlink@1.0.1 
  ├─┬ discord.js@11.0.0 
  │ ├── @types/node@6.0.60 
  │ ├── pako@1.0.4 
  │ ├─┬ superagent@3.3.2 
  │ │ ├── component-emitter@1.2.1 
  │ │ ├── cookiejar@2.1.0 
  │ │ ├─┬ debug@2.6.0 
  │ │ │ └── ms@0.7.2 
  │ │ ├── extend@3.0.0 
  │ │ ├─┬ form-data@2.1.2 
  │ │ │ ├── asynckit@0.4.0 
  │ │ │ ├─┬ combined-stream@1.0.5 
  │ │ │ │ └── delayed-stream@1.0.0 
  │ │ │ └─┬ mime-types@2.1.13 
  │ │ │   └── mime-db@1.25.0 
  │ │ ├── formidable@1.0.17 
  │ │ ├── methods@1.1.2 
  │ │ ├── mime@1.3.4 
  │ │ ├── qs@6.3.0 
  │ │ └─┬ readable-stream@2.2.2 
  │ │   ├── buffer-shims@1.0.0 
  │ │   ├── core-util-is@1.0.2 
  │ │   ├── inherits@2.0.3 
  │ │   ├── isarray@1.0.0 
  │ │   ├── process-nextick-args@1.0.7 
  │ │   ├── string_decoder@0.10.31 
  │ │   └── util-deprecate@1.0.2 
  │ ├── tweetnacl@0.14.5 
  │ └─┬ ws@1.1.1 
  │   ├── options@0.0.6 
  │   └── ultron@1.0.2 
  ├── UNMET PEER DEPENDENCY erlpack@hammerandchisel/erlpack#master
  ├─┬ irc@0.5.2 
  │ ├─┬ iconv@2.2.1 
  │ │ └── nan@2.5.0 
  │ ├── irc-colors@1.3.1 
  │ └── node-icu-charset-detector@0.2.0 
  ├── lodash@4.17.4 
  ├── UNMET PEER DEPENDENCY node-opus@^0.2.0
  ├── UNMET PEER DEPENDENCY opusscript@^0.0.1
  ├── strip-json-comments@2.0.1 
  ├── UNMET PEER DEPENDENCY uws@^0.12.0
  └─┬ winston@2.3.0 
    ├── async@1.0.0 
    ├── colors@1.0.3 
    ├── cycle@1.0.3 
    ├── eyes@0.1.8 
    ├── isstream@0.1.2 
    └── stack-trace@0.0.9 

npm WARN discord.js@11.0.0 requires a peer of erlpack@hammerandchisel/erlpack#master but none was installed.
npm WARN discord.js@11.0.0 requires a peer of node-opus@^0.2.0 but none was installed.
npm WARN discord.js@11.0.0 requires a peer of opusscript@^0.0.1 but none was installed.
npm WARN discord.js@11.0.0 requires a peer of uws@^0.12.0 but none was installed.
striker@smavks:~$ discord-irc
-bash: /usr/local/bin/discord-irc: No such file or directory

EDIT: Fixed it, had to delete the old /user/local/bin/discord-irc binary. Looks like 2.1.7 installs to usr/bin instead, so I had to run hash -d discord-irc after installing to get bash to look in the new path.

ekmartin commented 7 years ago

@StrikerMan780 2.1.7 should be on npm. Did you manage to install it?

StrikerMan780 commented 7 years ago

Got it sorted out. Made a note on the bottom of my last post a while ago. Basically, 2.1.7 did install, but the old version got left behind even after doing npm remove -g discord-irc.

StrikerMan780 commented 7 years ago

Even though I upgraded my copy of Discord.js and Discord-irc, I still get random disconnects.

overfl0 commented 7 years ago

I ran discord-irc with in debug mode and left it running on screen until it disconnected (usually after 3-5 days)

These are the last output lines that were on the screen:

debug: Received debug event from Discord Heartbeat acknowledged
debug: Received debug event from Discord Sending heartbeat
debug: Received debug event from Discord Heartbeat acknowledged
debug: Received debug event from Discord Sending heartbeat
debug: Received debug event from Discord Connecting to gateway wss://gateway.discord.gg/?v=6&encoding=etf
error: Received error event from Discord
PF94 commented 3 years ago

this issue still persists more than 4 years later

CardinAlexandre commented 3 years ago

Experiencing the same issue 24 September 2021 🙃

ic-08 commented 2 years ago

Still have the same problem I'm not sure about discord.js but this issue is the same on discord.py too It's almost 2022🤣

HexiDev commented 1 year ago

Still a issue...

pseiler commented 1 year ago

project seems dead. But I do not have issuess like this with projects using discord.py But I also do not use discord-irc anymore