Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.well-known lookup isn't playing nicely with custom servers which don't support .well-known #7875

Open
peter-scholtens opened this issue Dec 16, 2018 · 15 comments

Comments

@peter-scholtens
Copy link
Contributor

Description

Trying to login with riot-web via https://riot.im/app/#/login using a alternative home server generates an error message "Cannot find homeserver"

Steps to reproduce

  • Browse to https://riot.im/app/#/login
  • Click 'custom server'
  • Fill the field home server URL with https://matrix4me.nl
  • Fill user field with @test.user2:matrix4me.nl (is an existing user)
    Immediately, the webpage repsonses with "Cannot find homeserver", even before typing a password.

Till last week the server was recognized, and users could login with credentials. Since 13 ... 14 december (or maybe earlier) it worked correctly: user could login.

Last week I did a server upgrade, mostly on tooling (I guess) using:
pip install --upgrade pip (didn't log the version update number)
pip install --upgrade setuptools (didn't log the version update number)
pip install https://github.com/matrix-org/synapse/tarball/master (was already 0.33.9)

Version information

For the web app:

  • Client: Ubuntu Linux 18.04
  • Client: Firefox, 64.0+build3-0ubuntu0.18.04.1, amd64.

Used synapse server:

  • Server: Synapse 0.33.9
  • Server: Debian 9 (stretch), 4.9.0-8-amd64 Leave room button #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64

Javascript errors

  • Failed to open log database: InvalidStateError
  • Failed to initialise rageshake: Error: Failed to open log database: InvalidStateError
  • XML Parsing Error: syntax error Location: https://riot.im/app/version?cachebuster=1544996746660 Line Number 1, Column 1:
  • Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://matrix4me.nl/.well-known/matrix/client. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
  • Object { err: Error, response: XMLHttpRequest, wkAction: "FAIL_ERROR" }

Observations

  • Other users reported error when starting a new session, while some of the existing sessions kept working.
@turt2live
Copy link
Member

This is almost certainly the new .well-known (auto discovery) interfering with your login. You could set up a .well-known file, although instructions are relatively limited here.

Instead, it may be easier to use your localpart (the bit between the @ and :, so @alice:example.org's localpart would be alice) and ensure the custom server option points to the right place.

@peter-scholtens
Copy link
Contributor Author

When I fill in only the localpart (test.user2), then I get the error "Failed to perform homeserver discovery". Still with correct server name and protocol "https://matrix4me.nl".

@turt2live
Copy link
Member

Well that's not supposed to happen :(

Does refreshing and trying from scratch help?

@peter-scholtens
Copy link
Contributor Author

You mean the server? I've rebooted it. Didn't help. And the tarball does not have memory of previous versions...

@turt2live
Copy link
Member

I meant riot-web. It shouldn't be complaining about homeserver discovery if you're using your localpart.

@peter-scholtens
Copy link
Contributor Author

I don't own https://riot.im/app/#/login so I cannot do much. Currently I've not my own server running for the riot-web, only for synapse.

@lampholder
Copy link
Member

@peter-scholtens I suspect you'd be able to log in if you:

This is almost certainly the new .well-known (auto discovery) interfering with your login. You could set up a .well-known file, although instructions are relatively limited here.

@turt2live I'm going to rename this bug to reflect this likely cause

@lampholder lampholder changed the title Cannot find homeserver .well-known lookup isn't playing nicely with custom servers which don't support .well-known Dec 20, 2018
@turt2live
Copy link
Member

I think the stuck error problem is #7845. The lack of documentation is more or less #7760. The interference is something that we might not be able to solve without design.

@peter-scholtens
Copy link
Contributor Author

@lampholder I tried from several networks, with and without "@" and ":matrix4me.nl". All fail with "Cannot find homeserver".

@lampholder
Copy link
Member

#7977 is another report of the same thing with some potentially-useful discussion

@schildbach
Copy link

I've got the same issue. The "only use localpart" workaround did not help for me either. I'm still using matrix-synapse 0.24.0+dfsg-1, that's what comes with Ubuntu 18.04 LTS.

@MTRNord
Copy link
Contributor

MTRNord commented Jan 9, 2019

@schildbach I have the same issue. It especially breaks when the browser auto inputs fields with non user data :/ It seems like to try to use it as mxid but than locks up in a wrong state. I had to disable browser auto input, prevent to focus the localpart field and first type the new custom server ip and after that my localpart and password to get it to login at all

@turt2live
Copy link
Member

The stuck error is #7845 and a different issue

@julienschmidt
Copy link

julienschmidt commented Feb 4, 2019

We started using the .well-known/matrix/server file for our server recently and one user reported the same problem with our riot-web setup (however, somehow just on Windows, regardless of the used browser).

I think there are two problems here:

  1. riot-web very likely makes a cross-origin request when it tries to load the .well-known/matrix/client file (unless riot-web is running on the exact same domain), which means that the server has to send a Access-Control-Allow-Origin: * or similar header, as a CORS request requires to make a HEAD request first and check if access is allowed. This should be documented (see Document .well-known setup, etc (including ACAO headers) #7760).
  2. Web servers (e.g. nginx) usually don't send such headers on errors. E.g. if one would set add_header Access-Control-Allow-Origin *; in the nginx config, it might still not work. In our case the problem was that .well-known/matrix/client did not exist (while .well-known/matrix/server DID exist), thus causing a 404 error which then does not send the required header. One can fix that either by using add_header Access-Control-Allow-Origin * always; or by creating the missing file. It would however probably be a good idea to catch failed requests for .well-known/matrix/client (which then have the status code 0) in riot-web and treat them like the file does not exist.

@aaronraimist
Copy link
Collaborator

aaronraimist commented Feb 19, 2019

@turt2live so it seems like the problem is

if (response.statusCode === 404) {
    action = "IGNORE";
    reason = "No .well-known JSON file found";
}

https://github.com/matrix-org/matrix-js-sdk/blob/03a54353be98941c7e8c124393b386d0b6affc6f/src/autodiscovery.js#L366

If I comment out the if statement then it won't display an error message if the homeserver has no .well-known/matrix/client file. The reason it can't see the 404 is because of CORS.

With the check for 404:
screen shot 2019-02-18 at 9 33 41 pm
Error message to user: Invalid homeserver discovery response

Without the check for 404:
screen shot 2019-02-18 at 9 38 50 pm
No error message to user

The downside of commenting this out is no user facing error message will appear if the file does exist but it can't be accessed due to CORS. Maybe that's an OK compromise?

su-ex added a commit to SchildiChat/element-web that referenced this issue Mar 17, 2022
* Fix a bug where URL previews could be enabled in the left-panel when they
should not have been.
* Add a config.json option to skip the built-in Jitsi welcome screen ([\element-hq#21190](element-hq#21190)).
* Add unexposed account setting for hiding poll creation ([\#7972](matrix-org/matrix-react-sdk#7972)).
* Allow pinning polls ([\element-hq#7922](matrix-org/matrix-react-sdk#7922)). Fixes element-hq#20152.
* Make trailing `:` into a setting ([\element-hq#6711](matrix-org/matrix-react-sdk#6711)). Fixes element-hq#16682. Contributed by @SimonBrandner.
* Location sharing > back button ([\element-hq#7958](matrix-org/matrix-react-sdk#7958)).
* use LocationAssetType ([\element-hq#7965](matrix-org/matrix-react-sdk#7965)).
* Location share type UI ([\element-hq#7924](matrix-org/matrix-react-sdk#7924)).
* Add a few more UIComponent flags, and ensure they are used in existing code ([\element-hq#7937](matrix-org/matrix-react-sdk#7937)).
* Add support for overriding strings in the app ([\element-hq#7886](matrix-org/matrix-react-sdk#7886)).
* Add support for redirecting to external pages after logout ([\element-hq#7905](matrix-org/matrix-react-sdk#7905)).
* Expose redaction power level in room settings ([\element-hq#7599](matrix-org/matrix-react-sdk#7599)). Fixes element-hq#20590. Contributed by @SimonBrandner.
* Update and expand ways to access pinned messages ([\#7906](matrix-org/matrix-react-sdk#7906)). Fixes element-hq#21209 and element-hq#21211.
* Add slash command to switch to a room's virtual room ([\element-hq#7839](matrix-org/matrix-react-sdk#7839)).
* Remove Lojban translation ([\element-hq#21302](element-hq#21302)).
* Merge pull request from GHSA-qmf4-7w7j-vf23 ([\element-hq#8059](matrix-org/matrix-react-sdk#8059)).
* Add another null guard for member ([\element-hq#7984](matrix-org/matrix-react-sdk#7984)). Fixes element-hq#21319.
* Fix room account settings ([\element-hq#7999](matrix-org/matrix-react-sdk#7999)).
* Fix missing summary text for pinned message changes ([\element-hq#7989](matrix-org/matrix-react-sdk#7989)). Fixes element-hq#19823.
* Pass room to getRoomTombstone to avoid racing with setState ([\element-hq#7986](matrix-org/matrix-react-sdk#7986)).
* Hide composer and call buttons when the room is tombstoned ([\element-hq#7975](matrix-org/matrix-react-sdk#7975)). Fixes element-hq#21286.
* Fix bad ternary statement in autocomplete user pill insertions ([\element-hq#7977](matrix-org/matrix-react-sdk#7977)). Fixes element-hq#21307.
* Fix sending locations into threads and fix i18n ([\element-hq#7943](matrix-org/matrix-react-sdk#7943)). Fixes element-hq#21267.
* Fix location map attribution rendering over message action bar ([\element-hq#7974](matrix-org/matrix-react-sdk#7974)). Fixes element-hq#21297.
* Fix wrongly asserting that PushRule::conditions is non-null ([\element-hq#7973](matrix-org/matrix-react-sdk#7973)). Fixes element-hq#21305.
* Fix account & room settings race condition ([\element-hq#7953](matrix-org/matrix-react-sdk#7953)). Fixes element-hq#21163.
* Fix bug with some space selections not being applied ([\element-hq#7971](matrix-org/matrix-react-sdk#7971)). Fixes element-hq#21290.
* Revert "replace all require(.svg) with esm import" ([\element-hq#7969](matrix-org/matrix-react-sdk#7969)). Fixes element-hq#21293.
* Hide unpinnable pinned messages in more cases ([\element-hq#7921](matrix-org/matrix-react-sdk#7921)).
* Fix room list being laggy while scrolling 🐌 ([\element-hq#7939](matrix-org/matrix-react-sdk#7939)). Fixes element-hq#21262.
* Make pinned messages more reliably reflect edits ([\element-hq#7920](matrix-org/matrix-react-sdk#7920)). Fixes element-hq#17098.
* Improve accessibility of the BetaPill ([\element-hq#7949](matrix-org/matrix-react-sdk#7949)). Fixes element-hq#21255.
* Autofocus correct composer after sending reaction ([\element-hq#7950](matrix-org/matrix-react-sdk#7950)). Fixes element-hq#21273.
* Consider polls as message events for rendering redactions ([\element-hq#7944](matrix-org/matrix-react-sdk#7944)). Fixes element-hq#21125.
* Prevent event tiles being shrunk/collapsed by flexbox ([\element-hq#7942](matrix-org/matrix-react-sdk#7942)). Fixes element-hq#21269.
* Fix ExportDialog title on export cancellation ([\element-hq#7936](matrix-org/matrix-react-sdk#7936)). Fixes element-hq#21260. Contributed by @luixxiul.
* Mandate use of js-sdk/src/matrix import over js-sdk/src ([\element-hq#7933](matrix-org/matrix-react-sdk#7933)). Fixes element-hq#21253.
* Fix backspace not working in the invite dialog ([\element-hq#7931](matrix-org/matrix-react-sdk#7931)). Fixes element-hq#21249. Contributed by @SimonBrandner.
* Fix right panel soft crashes due to missing room prop ([\element-hq#7923](matrix-org/matrix-react-sdk#7923)). Fixes element-hq#21243.
* fix color of location share caret ([\element-hq#7917](matrix-org/matrix-react-sdk#7917)).
* Wrap all EventTiles with a TileErrorBoundary and guard parsePermalink ([\element-hq#7916](matrix-org/matrix-react-sdk#7916)). Fixes element-hq#21216.
* Fix changing space sometimes bouncing to the wrong space ([\element-hq#7910](matrix-org/matrix-react-sdk#7910)). Fixes element-hq#20425.
* Ensure EventListSummary key does not change during backpagination ([\element-hq#7915](matrix-org/matrix-react-sdk#7915)). Fixes element-hq#9192.
* Fix positioning of the thread context menu ([\element-hq#7918](matrix-org/matrix-react-sdk#7918)). Fixes element-hq#21236.
* Inject sender into pinned messages ([\element-hq#7904](matrix-org/matrix-react-sdk#7904)). Fixes element-hq#20314.
* Tweak info message padding in right panel timeline ([\#7901](matrix-org/matrix-react-sdk#7901)). Fixes element-hq#21212.
* Fix another freeze on room switch ([\#7900](matrix-org/matrix-react-sdk#7900)). Fixes element-hq#21127.
* Fix out of memory error when failing to acquire location ([\element-hq#7902](matrix-org/matrix-react-sdk#7902)). Fixes element-hq#21213.
* Fix edge case in context menu chevron positioning ([\element-hq#7899](matrix-org/matrix-react-sdk#7899)).
* Fix composer format buttons on WebKit ([\element-hq#7898](matrix-org/matrix-react-sdk#7898)). Fixes element-hq#20868.
* manage voicerecording state when deleting or sending a voice message ([\element-hq#7896](matrix-org/matrix-react-sdk#7896)). Fixes element-hq#21151.
* Fix bug with useRoomHierarchy tight-looping loadMore on error ([\element-hq#7893](matrix-org/matrix-react-sdk#7893)).
* Fix upload button & shortcut not working for narrow composer mode ([\element-hq#7894](matrix-org/matrix-react-sdk#7894)). Fixes element-hq#21175 and element-hq#21142.
* Fix emoji insertion in thread composer going to the main composer ([\element-hq#7895](matrix-org/matrix-react-sdk#7895)). Fixes element-hq#21202.
* Try harder to keep context menus inside the window ([\element-hq#7863](matrix-org/matrix-react-sdk#7863)). Fixes element-hq#17527 and element-hq#18377.
* Fix edge case around event list summary layout ([\element-hq#7891](matrix-org/matrix-react-sdk#7891)). Fixes element-hq#21180.
* Fix event list summary 1 hidden message pluralisation ([\element-hq#7890](matrix-org/matrix-react-sdk#7890)). Fixes element-hq#21196.
* Fix vanishing recently viewed menu ([\element-hq#7887](matrix-org/matrix-react-sdk#7887)). Fixes element-hq#20827.
* Fix freeze on room switch ([\element-hq#7884](matrix-org/matrix-react-sdk#7884)). Fixes element-hq#21127.
* Check 'useSystemTheme' in quick settings theme switcher ([\element-hq#7809](matrix-org/matrix-react-sdk#7809)). Fixes element-hq#21061.
* Fix 'my threads' filtering to include participated threads ([\element-hq#7882](matrix-org/matrix-react-sdk#7882)). Fixes element-hq#20877.
* Remove log line to try to fix freeze on answering VoIP call ([\element-hq#7883](matrix-org/matrix-react-sdk#7883)).
* Support social login & password on soft logout page ([\element-hq#7879](matrix-org/matrix-react-sdk#7879)). Fixes element-hq#21099.
* Fix missing padding on server picker ([\element-hq#7864](matrix-org/matrix-react-sdk#7864)).
* Throttle RoomState.members handlers ([\element-hq#7876](matrix-org/matrix-react-sdk#7876)). Fixes element-hq#21127.
* Only show joined/invited in search dialog ([\element-hq#7875](matrix-org/matrix-react-sdk#7875)). Fixes element-hq#21161.
* Don't pillify code blocks ([\element-hq#7861](matrix-org/matrix-react-sdk#7861)). Fixes element-hq#20851 and element-hq#18687.
* Fix keyboard shortcut icons on macOS ([\element-hq#7869](matrix-org/matrix-react-sdk#7869)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants