sm00th / bitlbee-discord

Bitlbee plugin for Discord (http://discordapp.com)
GNU General Public License v2.0
291 stars 27 forks source link

Sending fails with error code 404 #182

Closed Ennea closed 5 years ago

Ennea commented 5 years ago

As of a few hours ago, sending messages often fails with error code 404, sometimes even with 200 (not throwing an error). After some investigation and talking about this issue in #bitlbee, it looks like bitlbee-discord's usage of the same nonce for every message is the culprit. Removing the nonce in discord-http.c, lines 530-531, allows all messages to go through without issue (but leads to other issues of course).

EionRobb on IRC mentioned that purple-discord uses random nonces (as they should be) and inserts them into a hash table for later checking for self messages, so I guess that's the go to approach to handle this issue.

seitzbg commented 5 years ago

Happening to me too.

Alcaro commented 5 years ago

So Discord is finally fixing the duplicate messages?

Hashtable = memory allocation = annoying. Instead, I'd recommend keeping our current 16-byte random nonce, but append an increasing integer (sequence number, current time, whatever); messages starting with the nonce are from us.

More specifically,

discord.h:61, add int seq; somewhere in the struct
discord-http.c:530, \"nonce\":\"%s\" -> \"nonce\":\"%s%d\", append add ++dd->seq to argument list
discord-handlers.c:618, g_strcmp0(nonce, dd->nonce) -> g_str_has_prefix(nonce, dd->nonce)

(can't test myself, I no longer use this tool)

KeepBotting commented 5 years ago

This issue affects me as well.

sm00th commented 5 years ago

Temporary disabled nonces until we have a proper solution.

sm00th commented 5 years ago

Should be properly fixed now, please reopen if there are still issues with sending messages.

fish-face commented 5 years ago

Unless I have failed to properly reload the plugin (I just compiled, installed, then restarted bitlbee with systemctl) I am still getting 404 errors. I am also getting other messages going missing without any error message. A common theme seems to be that the first message in a bunch I send goes through, but subsequent ones don't. E.g. I sent 3 between 21:26:17 and 21:26:37, but only the first appeared. I then sent another two at 21:31:21 and :24, but only the first appeared again.

These examples were not associated with 404 errors. An example involving them involved messages at 20:43:18, 20:47:43, 20:48:00 and 20:48:11. Same again (but note the wide gap.) A subsequent message at 21:09:58 was sent successfully.

sm00th commented 5 years ago

@fish-face did you also reconnect your irc client? If you did and still seeing this please get a debug log (see Debugging section in README).

dgw commented 5 years ago

Running into that issue (messages failing to send, without any error) is what prompted me to update my bitlbee-discord instance. Haven't seen any since, that I know of.