element-x-android icon indicating copy to clipboard operation
element-x-android copied to clipboard

I can't login to any homeserver at all: "We couldn't reach this homeserver"

Open ImMALWARE opened this issue 1 year ago • 21 comments

Steps to reproduce

  1. I download latest version from GitHub Releases
  2. Opened the app, click continue
  3. Why not matrix org, continue

Outcome

What did you expect?

Login and password prompt

What happened instead?

We couldn't reach this homeserver. Please check that you have entered the homeserver USL correctly. If the URL is correct, contact your homeserver administrator for further help.

No matter what homeserver I try to login, it always gives this error

Your phone model

POCO X5 Pro 5G

Operating system version

Android 14

Application version and app store

Element X 0.5.3

Homeserver

I tried a lot of homeserver, none worked, even matrix.org

Will you send logs?

Yes

Are you willing to provide a PR?

No

ImMALWARE avatar Sep 11 '24 23:09 ImMALWARE

You have an invalid global HTTP proxy set on your phone according to those logs. Try disabling it

frebib avatar Sep 12 '24 12:09 frebib

You have an invalid global HTTP proxy set on your phone according to those logs. Try disabling it

Umm? What proxy? I was connected to mobile data, no proxy is set up in Mobile APN settings. Now I'm connected to Wi-Fi. No proxy is set up in Wi-Fi network's settings. No VPNs are enabled. I also had AdAway installed, I disabled it, it didn't help, still getting same error. No issues with any other app, including Element (not x)

ImMALWARE avatar Sep 12 '24 13:09 ImMALWARE

Specifically I'm talking about the :0 proxy here Many others have had this same issue such that it's a reasonably well understood problem now:

2024-09-11T23:44:38.139385Z DEBUG elementx: Using global proxy | 
2024-09-11T23:44:38.142840Z  INFO matrix_sdk::http_client::native: Setting the proxy for the HTTP client proxy_url=":0" | crates/matrix-sdk/src/http_client/native.rs:176 | spans: build{homeserver=ServerNameOrHomeserverUrl("https://matrix.org")}

frebib avatar Sep 12 '24 13:09 frebib

Specifically I'm talking about the :0 proxy here Many others have had this same issue such that it's a reasonably well understood problem now:

2024-09-11T23:44:38.139385Z DEBUG elementx: Using global proxy | 
2024-09-11T23:44:38.142840Z  INFO matrix_sdk::http_client::native: Setting the proxy for the HTTP client proxy_url=":0" | crates/matrix-sdk/src/http_client/native.rs:176 | spans: build{homeserver=ServerNameOrHomeserverUrl("https://matrix.org")}

Oh, is it issue with my android settings or with element x app?

ImMALWARE avatar Sep 12 '24 13:09 ImMALWARE

Probably your OS settings

frebib avatar Sep 12 '24 14:09 frebib

Probably your OS settings

How do I disable that proxy?

I was connected to mobile data, no proxy is set up in Mobile APN settings. Now I'm connected to Wi-Fi. No proxy is set up in Wi-Fi network's settings. No VPNs are enabled. I also had AdAway installed, I disabled it, it didn't help

ImMALWARE avatar Sep 12 '24 14:09 ImMALWARE

Probably your OS settings

Wait, doesn't ":0" mean "no proxy"? image image

ImMALWARE avatar Sep 13 '24 11:09 ImMALWARE

Here's a discussion where several other users have had this issue beforehand https://matrix.to/#/!aCvOWKNDeXXpPgquKq:matrix.org/$omg7ZqwN8XJYoBjjUDGVtE0WMVTjij4gRn_ajJElwwE?via=nerdhouse.io&via=matrix.org&via=envs.net

frebib avatar Sep 15 '24 09:09 frebib

can confirm this issues with SAMSUNG SM-N910T on Android 14 I believe it's not related to some proxy settings as I have not found nothing in logcat

532910 avatar Jan 21 '25 13:01 532910

can confirm this issues with SAMSUNG SM-N910T on Android 14 I believe it's not related to some proxy settings as I have not found nothing in logcat

open termux, enter "su" and execute commands:

settings delete global http_proxy
settings delete global global_http_proxy_host
settings delete global global_http_proxy_port

ImMALWARE avatar Jan 21 '25 13:01 ImMALWARE

no root on that phone

532910 avatar Jan 21 '25 14:01 532910

that phone succesfully downloads well-known from my homeserver

532910 avatar Jan 21 '25 14:01 532910

not fixed, please reopen

532910 avatar Jan 21 '25 14:01 532910

@532910, can you try to do the same thing via adb shell from pc?

ImMALWARE avatar Jan 23 '25 05:01 ImMALWARE

it was done from pc

532910 avatar Jan 23 '25 05:01 532910

@532910, maybe factory reset?...

ImMALWARE avatar Jan 23 '25 05:01 ImMALWARE

no way

532910 avatar Jan 23 '25 05:01 532910

@532910, well ok i will reopen

ImMALWARE avatar Jan 23 '25 05:01 ImMALWARE

  1. old element and all other apps works perfect
  2. element x successfully downloads well-known file from my home-server

532910 avatar Jan 23 '25 05:01 532910

@532910 @ImMALWARE The reason that Element X Android can download the well known is that it uses the Retrofit library to download this well known,

and here's the interesting thing:

That :0 proxy had an interesting behaviour, if set as the http proxy (for example, with adb shell settings put global http_proxy :0, I did this in an emulator), the system-wide ProxySelector will consider that we have no proxy, thus:

import java.net.ProxySelector
import java.net.URI

ProxySelector.getDefault().select(URI("http://example.com"))
# Returns a single entry [Proxy.NO_PROXY]

Retrofit uses OkHttp and by default inherits this system behaviour.

Rust isn't like that and will validate this proxy string, thus errored out.

I guess this should also applies to classic Element and other apps.

ShadowRZ avatar Apr 30 '25 07:04 ShadowRZ

same problem, the home server works on other devices like linux and browser, and all other apps on the phone work fine, just the element x login doesn't work, neither in mobile internet, nor in wifi. pls consider fixing as the old app is not available anymore via google play.

simon-ging avatar May 19 '25 11:05 simon-ging

my fix was to install the old app via f-droid.

simon-ging avatar May 19 '25 12:05 simon-ging

mmh, some VPN or other firewall app was setting Android's HTTP proxy settings to ":0" which rust apparently considers an invalid proxy. So from the app's point of view nothing to be fixed, as it is debatable whether ":0" is a valid HTTP proxy entry (aka don't use any) or an invalid one (preventing connections).

The proper fix is to remove the HTTP value which could also cause problems for other applications besides EXA

spaetz avatar May 19 '25 14:05 spaetz

The proper fix is to remove the HTTP value which could also cause problems for other applications besides EXA

No I don't think that this value would trip most other apps, as this :0 proxy also won't cause any problems in Element Android, as it's using OkHttp via Retrofit. See for example https://github.com/element-hq/element-x-android/issues/3447#issuecomment-2608921725 In some cases removing this value isn't possible as in https://github.com/element-hq/element-x-android/issues/3447#issuecomment-2604862012 and https://github.com/element-hq/element-x-android/issues/3447#issuecomment-2608920021

So from the app's point of view nothing to be fixed, as it is debatable whether ":0" is a valid HTTP proxy entry (aka don't use any) or an invalid one (preventing connections).

I have written technical details in https://github.com/element-hq/element-x-android/issues/3447#issuecomment-2841110041 but to reiterate: The :0 proxy would make system believe we have no proxy defined, therefore: At least in Android system it means "don't use any".

ShadowRZ avatar May 19 '25 14:05 ShadowRZ

I had this exact issue and solved it, by adding this block to my nginx conf:

(this should be already part of it):

` listen 443 ssl http2; listen [::]:443;

listen 8448 ssl http2 default_server; listen [::]:8448 ssl http2 default_server;

server_name your.awesomematrixserver.com; `

and then this:

# Federation Discovery (.well-known for other servers) location = /.well-known/matrix/server { return 200 '{"m.server": "your.awesomematrixserver.com:8448"}'; default_type application/json; add_header Access-Control-Allow-Origin *; }

Hope that helps.

RandomBloke85 avatar Jun 27 '25 15:06 RandomBloke85

I guess this should also applies to classic Element and other apps.

classic Element works fine on that phone (where element x is unable to login)

532910 avatar Jul 28 '25 06:07 532910

I guess this should also applies to classic Element and other apps.

classic Element works fine on that phone (where element x is unable to login)

Have the same issue, can this be fixed on the client side or does the server configuration need to be adjusted?

Curve avatar Oct 26 '25 20:10 Curve

I guess this should also applies to classic Element and other apps.

classic Element works fine on that phone (where element x is unable to login)

Have the same issue, can this be fixed on the client side or does the server configuration need to be adjusted?

The http proxy issue, which is the reason why this bug has been filed has been fixed. If you receive this error with EXA, you either have a very old synapse server (which does not support sliding sync), or your .well-known/client file is not set up correctly.

You might be able to work around misconfigured servers by directly entering the home server base url with a https://myhomeserver.com.

spaetz avatar Oct 27 '25 18:10 spaetz

I guess this should also applies to classic Element and other apps.

classic Element works fine on that phone (where element x is unable to login)

Have the same issue, can this be fixed on the client side or does the server configuration need to be adjusted?

The http proxy issue, which is the reason why this bug has been filed has been fixed. If you receive this error with EXA, you either have a very old synapse server (which does not support sliding sync), or your .well-known/client file is not set up correctly.

You might be able to work around misconfigured servers by directly entering the home server base url with a https://myhomeserver.com.

Could you elaborate on the last part? When signing in manually, I should enter the account provider with a https prefix? This also doesn't work for me sadly

The server I'm trying to connect to is running 1.138.4 if I looked it up correctly.

Curve avatar Oct 27 '25 18:10 Curve