matrix-org / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://matrix-org.github.io/synapse
Apache License 2.0
11.8k stars 2.13k forks source link

`register_new_matrix_user` can't deal with unix socket listeners #16390

Open Sir-Photch opened 1 year ago

Sir-Photch commented 1 year ago

Description

I have configured an unix-socket as a listener in homeserver.yaml, without listening on ports, on a newly configured synapse instance.

This way, register_new_matrix_user crashes.

Steps to reproduce

Homeserver

self-hosted synapse

Synapse Version

1.92.1

Installation Method

Other (please mention below)

Database

single pgsql 15.4, fresh setup

Workers

Single process

Platform

archlinux arm

Configuration

listeners:
  - path: /run/synapse/homeserver.sock
    mode: 660
    type: http
    resources:
      - names: [client, federation]

Relevant log output

not relevant

Anything else that would be useful to know?

Error Traceback:

Traceback (most recent call last):
  File "/usr/bin/register_new_matrix_user", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3.11/site-packages/synapse/_scripts/register_new_matrix_user.py", line 247, in main
    server_url = _find_client_listener(config)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/synapse/_scripts/register_new_matrix_user.py", line 309, in _find_client_listener
    return f"http://localhost:{listener['port']}"
                               ~~~~~~~~^^^^^^^^
KeyError: 'port'
Sir-Photch commented 1 year ago

This script obviously expects listening to happen on a port, which is not the case for sockets. But also, the requests-library does not seem to support unix sockets.

Temporarily adding a port listener works around this issue.

aceArt-GmbH commented 1 year ago

I resolved this by giving the script the reverse proxy address