GithubHelp home page GithubHelp logo

Comments (7)

sm00th avatar sm00th commented on July 19, 2024

Do you know if discord's webapp work from that machine? If you don't have a browser on that host you can check if discordapp.com and their ws gateway are available. You should get something like this:

$ curl -L http://discordapp.com/api/gateway
{"message": ""}

$ curl -i -H 'Upgrade: websocket' https://gateway-1.discord.gg/1
HTTP/1.1 400 Bad Request
connection: close
server: Cowboy
date: Tue, 15 Mar 2016 17:39:51 GMT
content-length: 0

If all looks good and it is not a network issue you can try running bitlbee in gdb and getting a backtrace of whats going on in the middle of those 2 minutes, or I can come up with a small debug patch for you to try.

from bitlbee-discord.

bleader avatar bleader commented on July 19, 2024

The curl commands worked as expected, and got me the same output you mentioned.

For gdb, I got some odd errors about bad address when doing a backtrace, I could still do a debug build, but the issue looks like it is coming from gdb on this system... I guess debugging the debugger is not the best way to go forward with this :)

By looking at discord_login_http() I suspected the http_dorequest() call would stall, but apparently not, I used BITLBEE_DEBUG=1 to get the http requests logs, and it seems to process multiple requests... getting 301 moved mulitple times, but there are no error code, all request seems to either get 301 or 200 codes:

About to send HTTP request:
POST /api/auth/login HTTP/1.1
Host: discordapp.com
User-Agent: Bitlbee-Discord
Content-Type: application/json
Content-Length: 55

{"email":"XXXXXXXXXXXXXX","password":"XXXXXXX"}
HTTP response headers:
HTTP/1.1 301 Moved Permanently
Date: Wed, 16 Mar 2016 09:55:20 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: __cfduid=dcb27bdc521a3a9a4bcb99b66d48ba03f1458122120; expires=Thu, 16-Mar-17 09:55:20 GMT; path=/; domain=.discordapp.com; HttpOnly
Location: https://discordapp.com/api/auth/login
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Via: 1.1 google
Server: cloudflare-nginx
CF-RAY: 28475432c6a13c3b-CDG

New headers for redirected HTTP request:
POST /api/auth/login HTTP/1.1
Host: discordapp.com
User-Agent: Bitlbee-Discord
Content-Type: application/json
Content-Length: 55

{"email":"XXXXXXXXXXXXXX","password":"XXXXXXX"}
HTTP response headers:
HTTP/1.1 200 OK
Server: cloudflare-nginx
Date: Wed, 16 Mar 2016 09:55:21 GMT
Content-Type: application/json
Content-Length: 72
Connection: keep-alive
Set-Cookie: __cfduid=d5220c54d568655b65e86f4d2965570cf1458122120; expires=Thu, 16-Mar-17 09:55:20 GMT; path=/; domain=.discordapp.com; HttpOnly
Strict-Transport-Security: max-age=31536000; includeSubdomains
Via: 1.1 google
CF-RAY: 28475435acb7151b-CDG

Finishing HTTP request with status: 200 OK
About to send HTTP request:
GET /api/gateway HTTP/1.1
Host: discordapp.com
User-Agent: Bitlbee-Discord
Content-Type: application/json
authorization: xxxxx


HTTP response headers:
HTTP/1.1 301 Moved Permanently
Date: Wed, 16 Mar 2016 09:55:21 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: __cfduid=dfe0e8c36fa0c1137394cb33a78e16b8b1458122121; expires=Thu, 16-Mar-17 09:55:21 GMT; path=/; domain=.discordapp.com; HttpOnly
Location: https://discordapp.com/api/gateway
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Via: 1.1 google
Server: cloudflare-nginx
CF-RAY: 2847543956f31515-CDG

New headers for redirected HTTP request:
GET /api/gateway HTTP/1.1
Host: discordapp.com
User-Agent: Bitlbee-Discord
Content-Type: application/json
authorization: xxxxxxx

HTTP response headers:
HTTP/1.1 200 OK
Server: cloudflare-nginx
Date: Wed, 16 Mar 2016 09:55:21 GMT
Content-Type: application/json
Content-Length: 39
Connection: keep-alive
Set-Cookie: __cfduid=d33fd17b68eede11fc9ca49503e13172d1458122121; expires=Thu, 16-Mar-17 09:55:21 GMT; path=/; domain=.discordapp.com; HttpOnly
Strict-Transport-Security: max-age=31536000; includeSubdomains
Via: 1.1 google
CF-RAY: 2847543c2ffc1067-CDG

Finishing HTTP request with status: 200 OK

All this happens quickly and after this last request it sits there waiting and I finally get the timeout on the bitlbee control channel.

I can add debug myself but seeing this I don't really know what to add. I thought about trying to avoid the 301 by using diretly 443 with ssl enabled in http_dorequest() but I guess you would have encountered the issue yourself if that was actually an issue.

from bitlbee-discord.

bleader avatar bleader commented on July 19, 2024

Did give it a shot with 443/ssl enabled in requests, no more 301 but same result, just less requests.

from bitlbee-discord.

sm00th avatar sm00th commented on July 19, 2024

So http(s) part is good, the problem is with websockets then. To enable libwebsockets debugging you can change the discord-websockets.c:200 line, so that it is 256(should be enough, but you can also try 512) instead of 0.

from bitlbee-discord.

bleader avatar bleader commented on July 19, 2024

Ok, I ended up _OR_ing all the log levels as neither 256 nor 512 helped, they match client and latency, and the interesting message was an err:

[1458208715:6624] ERR: server's cert didn't look good, X509_V_ERR = 20: error:00000014:lib(0):func(0):SSL lib

The issue likely lies within the older openssl on my system...

I also tried to change
discord-http.c:88 dd->gateway->wss = 1;

to = 2 thus allowing self signed certificates but no changes. Just like the 443/ssl this would have impacted other people than I if it was an issue, so I think the issue can be the older openssl.

from bitlbee-discord.

sm00th avatar sm00th commented on July 19, 2024

Ok, I ended up ORing all the log levels as neither 256 nor 512 helped

oh, right, I forgot how to use that already

[1458208715:6624] ERR: server's cert didn't look good, X509_V_ERR = 20: error:00000014:lib(0):func(0):SSL lib

The error doesn't look like it is caused by a self-signed cert, and indeed can be caused by old openssl version. As far as I remember discord's gateways don't support nonssl connections, so forcing wss = 0 is not likely to help here as well.

from bitlbee-discord.

bleader avatar bleader commented on July 19, 2024

oh, right, I forgot how to use that already
Not a problem :)

I gave a shot at installing 1.0.2g from packages, rebuilt bitlbee/libwebsockets/bitlbee-discord, checked the ldd of libwebsocket.so and both libssl and libcrypto points to the newly installed one.

In fact the issue are the certificates, which are not bundled with openssl anymore, I just upgraded the FreeBSD ca_root_nss package, and it works... Sorry for the noise, as I expected from the very beginning, it wasn't related to bitlbee-discord, but I had no clue who else to ask for pointers, thanks, both for the plugin and for the help.

from bitlbee-discord.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.