sm00th / bitlbee-discord

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

discord - Login error: Failed to switch to websocket mode (and 400 bad request from cloudflare) #237

Open MatthewVernon opened 9 months ago

MatthewVernon commented 9 months ago

bitlbee-discord 0.4.3 bitlbee 3.6-1.3 [Debian bookworm]

After ~1y away, I tried using bitlbee to talk to discord again. My IRC client just reports:

<root> Trying to get all accounts connected...
<root> discord - Login error: Failed to switch to websocket mode
<root> discord - Logging in: Signing off..
<root> discord - Logging in: Reconnecting in 5 seconds..

Running bitlbee with BITLBEE_DEBUG=1 it looks like cloudflare is saying 400 bad request:

[14:43:22] >>> ((null)) discord_http_get 188
About to send HTTP request:
GET /api/gateway HTTP/1.1
Host: discordapp.com
User-Agent: Bitlbee-Discord
Content-Type: application/json
authorization: REDACTED

HTTP response headers:
HTTP/1.1 200 OK
Date: Wed, 27 Sep 2023 13:43:22 GMT
Content-Type: application/json
Content-Length: 35
Connection: keep-alive
strict-transport-security: max-age=31536000; includeSubDomains
Via: 1.1 google
Alt-Svc: h3=":443"; ma=86400
CF-Cache-Status: HIT
Age: 72869
Last-Modified: Tue, 26 Sep 2023 17:28:53 GMT
Expires: Wed, 27 Sep 2023 13:43:52 GMT
Cache-Control: public, max-age=30
Accept-Ranges: bytes
Set-Cookie: __cf_bm=REDACTED; path=/; expires=Wed, 27-Sep-23 14:13:22 GMT; domain=.discordapp.com; HttpOnly; Secure; SameSite=None
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=REDACTED"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: REDACTED

Finishing HTTP request with status: 200 OK
[14:43:22] <<< ((null)) discord_http_gateway_cb [200] 35
{"url":"wss://gateway.discord.gg"}

[14:43:22] <<< ((null)) discord_ws_in_cb switching failure. buf:
HTTP/1.1 400 Bad Request
Server: cloudflare
Date: Wed, 27 Sep 2023 13:43:22 GMT
Content-Type: text/html
Content-Length: 155
Connection: close
CF-RAY: -

<html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>cloudflare</center>
</body>
</html>

[14:43:27] >>> ((null)) discord_http_get 188
About to send HTTP request:
GET /api/gateway HTTP/1.1
Host: discordapp.com
User-Agent: Bitlbee-Discord
Content-Type: application/json
authorization: REDACTED

HTTP response headers:
HTTP/1.1 200 OK
Date: Wed, 27 Sep 2023 13:43:27 GMT
Content-Type: application/json
Content-Length: 35
Connection: keep-alive
strict-transport-security: max-age=31536000; includeSubDomains
Via: 1.1 google
Alt-Svc: h3=":443"; ma=86400
CF-Cache-Status: HIT
Age: 72874
Last-Modified: Tue, 26 Sep 2023 17:28:53 GMT
Expires: Wed, 27 Sep 2023 13:43:57 GMT
Cache-Control: public, max-age=30
Accept-Ranges: bytes
Set-Cookie: __cf_bm=REDACTED; path=/; expires=Wed, 27-Sep-23 14:13:27 GMT; domain=.discordapp.com; HttpOnly; Secure; SameSite=None
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=REDACTED"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: REDACTED

Finishing HTTP request with status: 200 OK
[14:43:28] <<< ((null)) discord_http_gateway_cb [200] 35
{"url":"wss://gateway.discord.gg"}

[14:43:28] <<< ((null)) discord_ws_in_cb switching failure. buf:
HTTP/1.1 400 Bad Request
Server: cloudflare
Date: Wed, 27 Sep 2023 13:43:28 GMT
Content-Type: text/html
Content-Length: 155
Connection: close
CF-RAY: -

<html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>cloudflare</center>
</body>
</html>
sm00th commented 9 months ago

Might be cloudfare being suspicious of your bitlbee host's ip address. Could you try tunneling through that machine (ssh -D) and trying to log into discord with it's ip via browser?

MatthewVernon commented 9 months ago

The system I'm running bitlbee on is my desktop system (from which I've logged on via a web-browser)...

sm00th commented 9 months ago

I see. To be honest I've been neglecting this project for a while and I currently don't even have anything set up to properly test this issue and I am not sure when (or if) I'll have time for this.

My only other suggestion is trying re-create the account in bitlbee. If that doesn't help then probably other people are having this issue as well.