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

Matrix Dimension makes Matrix API call that 404s #2090

Closed
felix-two-tone opened this issue Sep 6, 2022 · 1 comment
Closed

Matrix Dimension makes Matrix API call that 404s #2090

felix-two-tone opened this issue Sep 6, 2022 · 1 comment

Comments

@felix-two-tone
Copy link

felix-two-tone commented Sep 6, 2022

Describe the bug
Matrix Dimension makes API call to upload media to Matrix at the address matrix-synapse:8008 and receives a 404

To Reproduce
My vars.yml file looks like this:

matrix_domain: XXXX
matrix_homeserver_implementation: synapse
matrix_homeserver_generic_secret_key: 'XXXX'
matrix_postgres_connection_password: 'XXXX'
matrix_synapse_workers_enabled: true
matrix_synapse_workers_preset: one-of-each
matrix_postgres_process_extra_arguments: [
  "-c 'max_connections=200'"
]
matrix_client_element_themes_enabled: true
matrix_nginx_proxy_enabled: false
matrix_mailer_sender_address: "XXXX"
matrix_mailer_relay_use: true
matrix_mailer_relay_host_name: "XXXX"
matrix_mailer_relay_host_port: 587
matrix_mailer_relay_auth: true
matrix_mailer_relay_auth_username: "XXXX"
matrix_mailer_relay_auth_password: "XXXX"
matrix_synapse_allow_public_rooms_over_federation: true
matrix_synapse_admin_enabled: true
matrix_synapse_enable_registration_captcha: true
matrix_synapse_recaptcha_public_key: 'XXXX'
matrix_synapse_recaptcha_private_key: 'XXXX'
matrix_synapse_enable_registration: true
matrix_dimension_enabled: true
matrix_dimension_admins:
  - "@XXX:XXX.XX"
matrix_dimension_access_token: "XXX"
matrix_dimension_configuration_extension_yaml: |
   telegram:
     botToken: "XXX"

In the integration manager for dimension, go to settings, the to import sticker packs. Input a sticker pack into the box and click submit. It will load for a second then give an error.

Found this bellow in the log:

Tue, 06 Sep 2022 03:49:38 GMT [INFO] [AdminStickerService] Importing https://t.me/addstickers/digimoji1 from Telegram for @XXX:XXX.XX
Tue, 06 Sep 2022 03:49:40 GMT [DEBUG] [DimensionStore [SQL]] Executing (default): INSERT INTO "dimension_sticker_packs" ("id","type","name","avatarUrl","description","isEnabled","isPublic","authorType","authorReference","authorName","license","licensePath") VALUES (DEFAULT,$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11) RETURNING "id","type","name","avatarUrl","description","isEnabled","isPublic","authorType","authorReference","authorName","license","licensePath","trackingRoomAlias";
Tue, 06 Sep 2022 03:49:40 GMT [INFO] [AdminStickerService] Importing sticker from https://api.telegram.org/file/XXXXX/stickers/file_71.webp
Tue, 06 Sep 2022 03:49:40 GMT [INFO] [matrix] Doing client API call: http://matrix-synapse:8008/_matrix/media/r0/upload
Tue, 06 Sep 2022 03:49:40 GMT [ERROR] [matrix] Got status code 404 while calling client endpoint /_matrix/media/r0/upload

Expected behavior
Dimension server connect to matrix-synapse and stickers are uploaded.

Matrix Server:

  • OS: Ubuntu 22.04
  • Architecture: amd64
  • nginx with the correct files included in the nginx.conf

Additional context
I believe this is the same issue as #1449

I also attemtped to change the Client/Server address in the config to no avail

spantaleev added a commit that referenced this issue Sep 14, 2022
@spantaleev
Copy link
Owner

This is because we point Dimension to matrix_homeserver_container_url, which.. if matrix-nginx-proxy is enabled, points to http://matrix-nginx-proxy:12080 -- a vhost, which can properly forward traffic to the appropriate Synapse worker:

# If Synapse workers are enabled and matrix-nginx-proxy is disabled, certain APIs may not work over 'http://matrix-synapse:{{ matrix_synapse_container_client_api_port }}'.
# This is because we explicitly disable them for the main Synapse process.
matrix_homeserver_container_url: |-
{{
'http://matrix-nginx-proxy:12080' if matrix_nginx_proxy_enabled else {
'synapse': ('http://matrix-synapse:'+ matrix_synapse_container_client_api_port|string),
'dendrite': ('http://matrix-dendrite:' + matrix_dendrite_http_bind_port|string),
'conduit': ('http://matrix-conduit:' + matrix_conduit_port_number|string),
}[matrix_homeserver_implementation]
}}

If matrix-nginx-proxy is disabled (like it is in your configuration), we can't point matrix_homeserver_container_url to http://matrix-nginx-proxy:12080 (because there is no such container), so we point it directly to Synapse's master process (http://matrix-synapse:8008). In that case: if Synapse workers are not enabled, we're still - the Synapse master process will handle all URL endpoints. If workers are enabled however, Synapse's master process will refuse to serve media_repository worker endpoints (like /_matrix/media/r0/upload), because it's the media_repository worker that is supposed to be serving those endpoints.


So.. your problem is that.. you're both enabling Synapse workers.. and disabling matrix-nginx-proxy.. A combination that is destined to bring you pain.

Consider keeping matrix-nginx-proxy enabled.. or disabling Synapse workers.

If you need another reverse proxy in front, you may be able to follow these docs: Fronting the integrated nginx reverse-proxy webserver with another reverse-proxy.

In 0581905 I've adjusted the documentation to make this more obvious.

spantaleev added a commit that referenced this issue Dec 20, 2022
This warning was added because of:
#2090

The problem has since been fixed by:
e9e8434

This current patch was provoked by:
#2352
mgoerens added a commit to mgoerens/matrix-docker-ansible-deploy that referenced this issue Apr 12, 2023
Similar to:
spantaleev@362954a

This warning was added because of:
spantaleev#2090

The problem has since been fixed by:
spantaleev@e9e8434

This current patch was provoked by:
spantaleev#2352
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants