element-hq / element-android

A Matrix collaboration client for Android.
https://element.io/
GNU Affero General Public License v3.0
3.34k stars 711 forks source link

this is not a valid matrix server address #3265

Open MeiRos opened 3 years ago

MeiRos commented 3 years ago

Describe the bug

There is red text at settings -> general -> home server. Last line. Below is retry button. "this is not a valid matrix server address" I have no idea what is wrong. Pretty much everything is working. Except some voice call problems. Can't receive calls with some phones if the screen is closed. But that's different thing. If I hit the retry button, it does something and text comes back.

To Reproduce

Steps to reproduce the behavior:

  1. Go to 'settings, general, home server'
  2. See error

Expected behavior

It would be nice to know what is wrong. We need a better error description.

Smartphone (please complete the following information):

Additional context

bmarty commented 3 years ago

Strange that the request does not works the first time and work the second. This request is using the federation API. Is the federation activated on your homeserver?

Also can you provide the url of your homeserver, or a screenshot of this screen, thanks

MeiRos commented 3 years ago

I haven't disabled the federation. This is how the federation tester sees it. Screenshot_20210430-230053_Brave

Here's the error. Screenshot_20210430-230455_Element

What do you mean about not working first and then working? If it's about after hitting retry, the error text is the text which comeback back.

bmarty commented 3 years ago

Ok, I see.

Can you try to run the following command in a console, and see what happens?

curl -X GET 'https://<HOMESERVER>/_matrix/federation/v1/version'

(replace <HOMESERVER> by your homeserver base url of course)

For instance on matrix.org we get:

curl -X GET 'https://matrix.org/_matrix/federation/v1/version'
{"server":{"name":"Synapse","version":"1.33.0rc1 (b=matrix-org-hotfixes,696e7df2e)"}}
MeiRos commented 3 years ago

If I use just domain.name

<html>                                                                          <head><title>404 Not Found</title></head>                                       <body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>

With matrix.domain.name I get

<html>
  <head><title>404 - No Such Resource</title></head>
  <body>
    <h1>No Such Resource</h1>
    <p>Sorry. No luck finding that resource.</p>
  </body>
</html>
DC7IA commented 2 years ago

This issue still exists, just came across it today.

NickCao commented 2 years ago

I'm seeing this issue, but at a different location: some room -> settings -> advanced -> room addresses -> local addresses, and my homeserver is dendrite 0.7.0 if that makes a difference.

rom4nik commented 2 years ago

Does any of you affected by this issue have the homeserver's federation listener on different port than client listener? I do, and it seems that Element doesn't respect the custom port set in https://domain.tld/.well-known/matrix/server for those requests, which also happen when I'm trying to log in using domain.tld, not actual server URL (matrix.domain.tld).

Curling https://<HOMESERVER>:federationport/_matrix/federation/v1/version gives me correct response, while the same request to port 443 (where client listener is, in my case) gives me a 404 as expected.

rom4nik commented 2 years ago

Poking around codebase leads me to believe that this is the culprit:

https://github.com/vector-im/element-android/blob/166d2a3ba0a5729a721ca74ae9fc34e4e953b239/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/federation/FederationModule.kt#L42

https://github.com/vector-im/element-android/blob/166d2a3ba0a5729a721ca74ae9fc34e4e953b239/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/data/SessionParams.kt#L58-L62