Closed nimogit closed 5 years ago
That means you haven't properly registered the appservice. Usually the problem is one of the following:
I followed the Production setup carefully, so at this level i'm suspecting that i misunderstood some config parameters.
here is what mautrix-telegram config.yaml looks like
homeserver: address: https://mysynapse.xyz domain: mysynapse.xyz verify_ssl: true appservice: address: http://localhost:8182 hostname: 0.0.0.0 port: 8182 max_body_size: 1 database: sqlite:///mautrix-telegram.db prefix: /public external: https://tb.mysynapse.xyz/public provisioning: enabled: true prefix: /_matrix/provision/v1 shared_secret: generate id: telegram bot_username: telegrambridge bot_displayname: Telegram bridge bot bot_avatar: mxc://maunium.net/tJCRmUyJDsgRNgqhOgoiHWbX as_token: "This value is generated when generating the registration" hs_token: "This value is generated when generating the registration" bridge: username_template: "telegram_{userid}" alias_template: "telegram_{groupname}" displayname_template: "{displayname} (Telegram)" displayname_preference: - full name - username - phone number max_initial_member_sync: -1 sync_channel_members: true skip_deleted_members: true startup_sync: true sync_dialog_limit: 30 max_telegram_delete: 10 sync_matrix_state: true allow_matrix_login: true plaintext_highlights: false edits_as_replies: true highlight_edits: false public_portals: true catch_up: false sync_with_custom_puppets: true telegram_link_preview: true inline_images: false image_as_file_size: 10 bot_messages_as_notices: true bridge_notices: default: false exceptions: - "@importantbot:mysynapse.xyz" deduplication: pre_db_check: false cache_queue_length: 20 message_formats: m.text: "$sender_displayname: $message" m.emote: "* $sender_displayname $message" m.file: "$sender_displayname sent a file: $message" m.image: "$sender_displayname sent an image: $message" m.audio: "$sender_displayname sent an audio file: $message" m.video: "$sender_displayname sent a video: $message" m.location: "$sender_displayname sent a location: $message" state_event_formats: join: "$displayname joined the room." leave: "$displayname left the room." name_change: "$prev_displayname changed their name to $displayname" filter: # Filter mode to use. Either "blacklist" or "whitelist". # If the mode is "blacklist", the listed chats will never be bridged. # If the mode is "whitelist", only the listed chats can be bridged. mode: blacklist list: [] command_prefix: "!tg" permissions: "*": "relaybot" "web.mysynapse.xyz": "user" "mysynapse.xyz": "full" "@root:mysynapse.xyz": "admin" relaybot: authless_portals: true whitelist_group_admins: true ignore_own_incoming_events: true whitelist: - root - admin telegram: api_id: myappid api_hash: myhash bot_token: disabled server: enabled: false dc: 2 ip: 149.154.167.40 port: 80 proxy: type: disabled address: 127.0.0.1 port: 1080 rdns: true username: "" password: "" logging: version: 1 formatters: precise: format: "[%(asctime)s] [%(levelname)s@%(name)s] %(message)s" handlers: file: class: logging.handlers.RotatingFileHandler formatter: precise filename: ./mautrix-telegram.log maxBytes: 10485760 backupCount: 10 console: class: logging.StreamHandler formatter: precise loggers: mau: level: DEBUG telethon: level: DEBUG aiohttp: level: INFO root: level: DEBUG handlers: [file, console]
and here is what synapse homeserver.yaml looks like
server_name: "mysynapse.xyz" report_stats: false tls_certificate_path: "/etc/matrix-synapse/ssl.mysynapse.xyz.crt" tls_private_key_path: "/etc/matrix-synapse/ssl.mysynapse.xyz.pem" no_tls: False tls_fingerprints: [] pid_file: "/var/run/matrix-synapse.pid" web_client: False public_baseurl: https://mysynapse.xyz/ soft_file_limit: 0 federation_domain_whitelist: - mysynapse.xyz listeners: - # The port to listen for HTTPS requests on. port: 8448 bind_addresses: - '::' - '0.0.0.0' type: http tls: true x_forwarded: false resources: - names: - client # The client-server APIs, both v1 and v2 - webclient # The bundled webclient. compress: true - names: [federation] # Federation APIs compress: false - port: 8008 tls: false bind_addresses: ['::', '0.0.0.0'] type: http x_forwarded: false resources: - names: [client, webclient] compress: true - names: [federation] compress: false database: name: "sqlite3" args: database: "/var/lib/matrix-synapse/homeserver.db" event_cache_size: "10K" log_config: "/etc/matrix-synapse/log.yaml" rc_messages_per_second: 0.2 rc_message_burst_count: 10.0 federation_rc_window_size: 1000 federation_rc_sleep_limit: 10 federation_rc_sleep_delay: 500 federation_rc_reject_limit: 50 federation_rc_concurrent: 3 media_store_path: "/var/lib/matrix-synapse/media" uploads_path: "/var/lib/matrix-synapse/uploads" max_upload_size: "10M" max_image_pixels: "32M" dynamic_thumbnails: false thumbnail_sizes: - width: 32 height: 32 method: crop - width: 96 height: 96 method: crop - width: 320 height: 240 method: scale - width: 640 height: 480 method: scale - width: 800 height: 600 method: scale url_preview_enabled: False max_spider_size: "10M" recaptcha_public_key: "YOUR_PUBLIC_KEY" recaptcha_private_key: "YOUR_PRIVATE_KEY" enable_registration_captcha: False recaptcha_siteverify_api: "https://www.google.com/recaptcha/api/siteverify" turn_uris: ["turn:myturn.mydomain.me?transport=udp", "turn:myturn.mydomain.me?transport=tcp"] turn_shared_secret: "somesecret" turn_user_lifetime: "86400000" turn_allow_guests: False enable_registration: True registrations_require_3pid: - email allowed_local_3pids: - medium: email pattern: '.*@students\.aub\.edu\.lb' - medium: msisdn pattern: '+961' registration_shared_secret: "somesecret" bcrypt_rounds: 12 allow_guest_access: False trusted_third_party_id_servers: - mysynapse.xyz auto_join_rooms: - "#welcome:mysynapse.xyz" enable_metrics: False room_invite_state_types: - "m.room.join_rules" - "m.room.canonical_alias" - "m.room.avatar" - "m.room.name" app_service_config_files: - /root/mtbridge/registration.yaml # macaroon_secret_key:expire_access_token: False signing_key_path: "/etc/matrix-synapse/mysynapse.xyz.signing.key" old_signing_keys: {} key_refresh_interval: "1d" # 1 Day. # The trusted servers to download signing keys from. perspectives: servers: "matrix.org": verify_keys: "ed25519:auto": key: "Noi6WqcDj0QmPxCNQqgezwTlBKrfqehY1u2FyWP9uYw" password_config: enabled: true email: enable_notifs: true smtp_host: "mysynapse.xyz" smtp_port: 465 smtp_user: "noreply@mysynapse.xyz" smtp_pass: "somepass" require_transport_security: False notif_from: "Your Friendly %(app)s Home Server " app_name: Name notif_template_html: notif_mail.html notif_template_text: notif_mail.txt notif_for_new_users: True riot_base_url: "https://web.mysynapse.xyz" push: include_content: true enable_group_creation: false
From this it seems to me that you missed Step 5 in the production setup, ie "Generate the appservice registration with python -m mautrix_telegram -g
" because your bridges config.yaml does show placeholders for as_token and hs_token.
This is the config.yaml before running python -m mautrix_telegram -g Just to be clear, I followed the guide exactly and after @tulir reply i repeated the steps over and over again just to make sure, so i deleted config.yaml, mautrix-telegram.db, registration.yaml and re-uploaded the config.yaml above with as_token, hs_token set to generate then i did run: python -m mautrix_telegram -g after that i restarted synapse recreated the database: alembic upgrade head then i did run: python -m mautrix_telegram but the same error kept happening, this why I'm suspecting that i might be missing/misunderstanding something in the config files
I was able to solve and start the bridge after all After serious time consuming digging, it appeared to be a miss configuration issue with synapse. Apparently i updated my synapse homeserver but not its config file, so sorry for the wasting your time and thank you for your help
(mtbridge) root@server4:~/mtbridge# python -m mautrix_telegram [2019-05-05 13:38:49,637] [DEBUG@mau.init] Initializing mautrix-telegram 0.5.1 [2019-05-05 13:38:49,680] [DEBUG@mau.init] Initialization complete in 0.0 seconds, running startup actions [2019-05-05 13:38:49,680] [DEBUG@mau.as.api] POST /register {"username": "telegrambridge"} as user No identity [2019-05-05 13:38:49,755] [ERROR@mau.as.intent] Failed to register @telegrambridge:mysynapsedomain.xyz! Traceback (most recent call last): File "/root/mtbridge/lib/python3.7/site-packages/mautrix_appservice/intent_api.py", line 898, in ensure_registered await self._register() File "/root/mtbridge/lib/python3.7/site-packages/mautrix_appservice/intent_api.py", line 136, in _send errcode=errcode, message=message) mautrix_appservice.errors.MatrixRequestError: 401: {"errcode":"M_UNKNOWN_TOKEN","error":"Unrecognised access token."} [2019-05-05 13:38:49,756] [DEBUG@mau.as.api] PUT /profile/@telegrambridge:mysynapsedomain.xyz/displayname {"displayname": "Telegram bridge bot"} as user No identity [2019-05-05 13:38:49,761] [ERROR@mau.init] Unexpected error Traceback (most recent call last): File "/root/mtbridge/lib/python3.7/site-packages/mautrix_telegram/main.py", line 138, in
loop.run_until_complete(asyncio.gather(*startup_actions, loop=loop))
File "/usr/local/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
return future.result()
File "/root/mtbridge/lib/python3.7/site-packages/mautrix_telegram/matrix.py", line 46, in init_as_bot
displayname if displayname != "remove" else "")
File "/root/mtbridge/lib/python3.7/site-packages/mautrix_appservice/intent_api.py", line 338, in set_display_name
await self.client.request("PUT", f"/profile/{self.mxid}/displayname", content)
File "/root/mtbridge/lib/python3.7/site-packages/mautrix_appservice/intent_api.py", line 136, in _send
errcode=errcode, message=message)
mautrix_appservice.errors.MatrixRequestError: 401: {"errcode":"M_UNKNOWN_TOKEN","error":"Invalid macaroon passed."}
I use synapse 0.99.2 with mxisd