matrix-rust-sdk icon indicating copy to clipboard operation
matrix-rust-sdk copied to clipboard

Cannot login to beta.matrix.org

Open martinetd opened this issue 4 months ago • 5 comments

Running example/login doesn't seem to be able to login to beta server:

matrix-rust-sdk/examples/login$ RUST_LOG=trace cargo run -- https://beta.matrix.org
    Finished `dev` profile [unoptimized] target(s) in 0.16s
     Running `/home/shared/matrix-rust-sdk/target/debug/example-login 'https://beta.matrix.org'`
2025-08-07T14:44:22.371839Z DEBUG build: matrix_sdk::client::builder: Starting to build the Client
2025-08-07T14:44:22.379060Z  INFO build{homeserver=HomeserverUrl("https://beta.matrix.org/")}: matrix_sdk::client::builder: selected sliding sync version version=Native
2025-08-07T14:44:22.379303Z DEBUG build{homeserver=HomeserverUrl("https://beta.matrix.org/")}: matrix_sdk::client::builder: Done building the Client
2025-08-07T14:44:22.379461Z TRACE send{request_id="REQ-0"}: matrix_sdk::http_client: Serializing request request_type="ruma_client_api::discovery::get_supported_versions::Request"
2025-08-07T14:44:22.379569Z DEBUG send{request_id="REQ-0" method=GET uri="https://beta.matrix.org/_matrix/client/versions"}: matrix_sdk::http_client::native: Sending request num_attempt=1
2025-08-07T14:44:22.379672Z TRACE send{request_id="REQ-0" method=GET uri="https://beta.matrix.org/_matrix/client/versions"}: hyper_util::client::legacy::pool: checkout waiting for idle connection: ("https", beta.matrix.org)
2025-08-07T14:44:22.379714Z DEBUG send{request_id="REQ-0" method=GET uri="https://beta.matrix.org/_matrix/client/versions"}: reqwest::connect: starting new connection: https://beta.matrix.org/    
2025-08-07T14:44:22.379738Z TRACE send{request_id="REQ-0" method=GET uri="https://beta.matrix.org/_matrix/client/versions"}: hyper_util::client::legacy::connect::http: Http::connect; scheme=Some("https"), host=Some("beta.matrix.org"), port=None
2025-08-07T14:44:22.473947Z DEBUG send{request_id="REQ-0" method=GET uri="https://beta.matrix.org/_matrix/client/versions"}: hyper_util::client::legacy::connect::http: connecting to 3.66.50.240:443
2025-08-07T14:44:22.733247Z DEBUG send{request_id="REQ-0" method=GET uri="https://beta.matrix.org/_matrix/client/versions"}: hyper_util::client::legacy::connect::http: connected to 3.66.50.240:443
2025-08-07T14:44:22.997221Z TRACE send{request_id="REQ-0" method=GET uri="https://beta.matrix.org/_matrix/client/versions"}: hyper_util::client::legacy::client: http1 handshake complete, spawning background dispatcher task
2025-08-07T14:44:22.997795Z TRACE send{request_id="REQ-0" method=GET uri="https://beta.matrix.org/_matrix/client/versions"}: hyper_util::client::legacy::pool: checkout dropped for ("https", beta.matrix.org)
2025-08-07T14:44:23.256892Z TRACE send{request_id="REQ-0" method=GET uri="https://beta.matrix.org/_matrix/client/versions"}: hyper_util::client::legacy::pool: put; add idle connection for ("https", beta.matrix.org)
2025-08-07T14:44:23.257000Z DEBUG send{request_id="REQ-0" method=GET uri="https://beta.matrix.org/_matrix/client/versions"}: hyper_util::client::legacy::pool: pooling idle connection for ("https", beta.matrix.org)
2025-08-07T14:44:23.257254Z DEBUG send{request_id="REQ-0" method=GET uri="https://beta.matrix.org/_matrix/client/versions"}: reqwest::async_impl::client: redirecting 'https://beta.matrix.org/_matrix/client/versions' to 'https://beta.element.io/'    
2025-08-07T14:44:23.257389Z TRACE send{request_id="REQ-0" method=GET uri="https://beta.matrix.org/_matrix/client/versions"}: hyper_util::client::legacy::pool: checkout waiting for idle connection: ("https", beta.element.io)
2025-08-07T14:44:23.257444Z DEBUG send{request_id="REQ-0" method=GET uri="https://beta.matrix.org/_matrix/client/versions"}: reqwest::connect: starting new connection: https://beta.element.io/    
2025-08-07T14:44:23.257491Z TRACE send{request_id="REQ-0" method=GET uri="https://beta.matrix.org/_matrix/client/versions"}: hyper_util::client::legacy::connect::http: Http::connect; scheme=Some("https"), host=Some("beta.element.io"), port=None
2025-08-07T14:44:23.258512Z TRACE hyper_util::client::legacy::pool: idle interval checking for expired
2025-08-07T14:44:23.339568Z DEBUG send{request_id="REQ-0" method=GET uri="https://beta.matrix.org/_matrix/client/versions"}: hyper_util::client::legacy::connect::http: connecting to 3.66.50.240:443
2025-08-07T14:44:23.596358Z DEBUG send{request_id="REQ-0" method=GET uri="https://beta.matrix.org/_matrix/client/versions"}: hyper_util::client::legacy::connect::http: connected to 3.66.50.240:443
2025-08-07T14:44:23.859160Z TRACE send{request_id="REQ-0" method=GET uri="https://beta.matrix.org/_matrix/client/versions"}: hyper_util::client::legacy::client: http1 handshake complete, spawning background dispatcher task
2025-08-07T14:44:23.859457Z TRACE send{request_id="REQ-0" method=GET uri="https://beta.matrix.org/_matrix/client/versions"}: hyper_util::client::legacy::pool: checkout dropped for ("https", beta.element.io)
2025-08-07T14:44:24.116149Z TRACE hyper_util::client::legacy::pool: put; add idle connection for ("https", beta.element.io)
2025-08-07T14:44:24.116221Z DEBUG hyper_util::client::legacy::pool: pooling idle connection for ("https", beta.element.io)
2025-08-07T14:44:24.116569Z DEBUG send{request_id="REQ-0" method=GET uri="https://beta.matrix.org/_matrix/client/versions" status=200 response_size="5.8k" request_duration=1.736749433s}: eyeball::state: No wakers
2025-08-07T14:44:24.116670Z DEBUG send{request_id="REQ-0" method=GET uri="https://beta.matrix.org/_matrix/client/versions" status=200 response_size="5.8k" request_duration=1.736749433s}: matrix_sdk::http_client: Error while sending request: Api(Deserialization(Json(Error("expected value", line: 1, column: 1))))
2025-08-07T14:44:24.116791Z DEBUG eyeball::state: No wakers
2025-08-07T14:44:24.117037Z DEBUG eyeball::state: No wakers
2025-08-07T14:44:24.117208Z DEBUG eyeball::state: No wakers
2025-08-07T14:44:24.117229Z DEBUG eyeball::state: No wakers
2025-08-07T14:44:24.117242Z DEBUG matrix_sdk::send_queue: globally dropping the send queue
2025-08-07T14:44:24.117342Z TRACE hyper_util::client::legacy::pool: pool closed, canceling idle interval
Error: deserialization failed: expected value at line 1 column 1

tested as ofl today's main branch, 669ebf240875350a5c804d1bc73a2a533f0dba36

I've never user beta.m.o before so I might be doing something wrong

martinetd avatar Aug 07 '25 14:08 martinetd

Hmm, looks like https://beta.matrix.org/.well-known/matrix/client/versions redirects to https://beta.element.io for some reason. This might be server misconfiguration; I'll try to report it to an Element devops room; thanks for letting us know!

bnjbvr avatar Aug 07 '25 15:08 bnjbvr

It might actually be an issue on our side: we're not using the m.homeserver.base_url defined in the .well-known/matrix/client file to do the requests 🤔

bnjbvr avatar Aug 07 '25 16:08 bnjbvr

It might actually be an issue on our side: we're not using the m.homeserver.base_url defined in the .well-known/matrix/client file to do the requests 🤔

This doesn't seem to be the issue. If I do a manual request to https://beta.matrix.org/_matrix/client/versions and follow the redirect I get this:

http https://beta.matrix.org/_matrix/client/versions -F    
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 5760
Content-Security-Policy: frame-ancestors 'self'; frame-ancestors 'self';
Content-Type: text/html; charset=utf-8
Date: Fri, 08 Aug 2025 13:09:25 GMT
ETag: "686bcf76-1680"
Last-Modified: Mon, 07 Jul 2025 13:45:26 GMT
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Robots-Tag: none
X-XSS-Protection: 1; mode=block

<!doctype html>
<html lang="en" style="height: 100%;">
  <head>
    <meta charset="utf-8">
    <title>Element</title>
...

Which doesn't look like the well-known file.

poljar avatar Aug 08 '25 13:08 poljar

@poljar These endpoints are confusing, note the behavior here:

  • https://beta.matrix.org/.well-known/matrix/client is to be pulled to figure out what's the homeserver base URL
  • once we have it, we should use $HOMESERVER_URL/_matrix/client/versions to get the versions

And we're not doing this in the code fetching versions.

That being said, we must be doing some kind of fetching of the homeserver base URL to build the initial client, or things would be broken in more obvious ways. To be investigated more.

bnjbvr avatar Aug 11 '25 07:08 bnjbvr

I believe this is just a misuse of the example.

The example asks for the homeserver URL, not the server name, because it doesn't try to do any auto-discovery, and https://beta.matrix.org is not the homeserver URL. beta.matrix.org is the server name, and https://beta.ems.host is the homeserver URL.

Now the example could be changed to use ClientBuilder::server_name_or_homeserver_url() rather than Client::new(), to perform auto-discovery.

zecakeh avatar Aug 19 '25 07:08 zecakeh