matrix-org / matrix-appservice-discord

A bridge between Matrix and Discord.
Apache License 2.0
790 stars 148 forks source link

Bridge doesn't seem to be starting #835

Closed hwittenborn closed 1 year ago

hwittenborn commented 1 year ago

I'm not sure why, but I can't get the bridge to start. Stuff is happening in the server logs, but the bridge user doesn't appear to be being created, nor can I make it join my rooms.

Here's the logs for the Discord bridge where the error starts happening:

Aug-23 01:18:01.985 [bot-sdkMatrixLiteClient (REQ-1)] error: [ { errcode: M_USER_IN_USE, error: User ID already taken. } ]
192.168.48.2 - - [23/Aug/2022:01:18:05 +0000] "PUT /transactions/148857?access_token={redacted} HTTP/1.1" 200 2 "-" "Synapse/1.65.0"
192.168.48.2 - - [23/Aug/2022:01:18:05 +0000] "PUT /transactions/148858?access_token={redacted} HTTP/1.1" 200 2 "-" "Synapse/1.65.0"
192.168.48.2 - - [23/Aug/2022:01:18:05 +0000] "PUT /transactions/148859?access_token={redacted} HTTP/1.1" 200 2 "-" "Synapse/1.65.0"
192.168.48.2 - - [23/Aug/2022:01:18:05 +0000] "PUT /transactions/148860?access_token={redacted} HTTP/1.1" 200 2 "-" "Synapse/1.65.0"
192.168.48.2 - - [23/Aug/2022:01:18:05 +0000] "PUT /transactions/148861?access_token={redacted} HTTP/1.1" 200 2 "-" "Synapse/1.65.0"
192.168.48.2 - - [23/Aug/2022:01:18:06 +0000] "PUT /transactions/148862?access_token={redacted} HTTP/1.1" 200 2 "-" "Synapse/1.65.0"
192.168.48.2 - - [23/Aug/2022:01:18:06 +0000] "PUT /transactions/148863?access_token={redacted} HTTP/1.1" 200 2 "-" "Synapse/1.65.0"
192.168.48.2 - - [23/Aug/2022:01:18:06 +0000] "PUT /transactions/148864?access_token={redacted} HTTP/1.1" 200 2 "-" "Synapse/1.65.0"
192.168.48.2 - - [23/Aug/2022:01:18:06 +0000] "PUT /transactions/148865?access_token={redacted} HTTP/1.1" 200 2 "-" "Synapse/1.65.0"
192.168.48.2 - - [23/Aug/2022:01:18:06 +0000] "PUT /transactions/148866?access_token={redacted} HTTP/1.1" 200 2 "-" "Synapse/1.65.0"
192.168.48.2 - - [23/Aug/2022:01:18:06 +0000] "PUT /transactions/148867?access_token={redacted} HTTP/1.1" 200 2 "-" "Synapse/1.65.0"
192.168.48.2 - - [23/Aug/2022:01:18:06 +0000] "PUT /transactions/148868?access_token={redacted} HTTP/1.1" 200 2 "-" "Synapse/1.65.0"
192.168.48.2 - - [23/Aug/2022:01:18:06 +0000] "PUT /transactions/148869?access_token={redacted} HTTP/1.1" 200 2 "-" "Synapse/1.65.0"
192.168.48.2 - - [23/Aug/2022:01:18:06 +0000] "PUT /transactions/148870?access_token={redacted} HTTP/1.1" 200 2 "-" "Synapse/1.65.0"
Aug-23 01:18:06.153 [DiscordAS] error: Exception thrown while handling "room.event" event Error: Room(s) not found.
    at DiscordBot.<anonymous> (/src/bot.ts:614:19)
    at Generator.next (<anonymous>)
    at fulfilled (/build/src/bot.js:20:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

Everything except that first line just keeps happening over and over past this current point.

I'm also getting things like this in my Matrix server logs over and over:

2022-08-23 01:27:38,186 - synapse.http.client - 446 - INFO - as-recoverer-discord-bridge-1 - Received response to PUT http://matrix-discord:9005/transactions/198270?access_token=<redacted>: 200
2022-08-23 01:27:38,192 - synapse.appservice.scheduler - 505 - INFO - as-recoverer-discord-bridge-1 - Retrying transaction 198271 for AS ID discord-bridge
2022-08-23 01:27:38,197 - synapse.http.client - 446 - INFO - as-recoverer-discord-bridge-1 - Received response to PUT http://matrix-discord:9005/transactions/198271?access_token=<redacted>: 200
2022-08-23 01:27:38,206 - synapse.appservice.scheduler - 505 - INFO - as-recoverer-discord-bridge-1 - Retrying transaction 198272 for AS ID discord-bridge

Here's my config and registration files as well:

config

bridge:
  domain: "hunterwittenborn.com"
  homeserverUrl: "https://matrix.hunterwittenborn.com"
  port: 9005
  presenceInterval: 500
  disablePresence: false
  disableTypingNotifications: false
  disableDeletionForwarding: false
  disablePortalBridging: false
  # Enable users to bridge rooms using !discord commands. See
  # https://t2bot.io/discord for instructions.
  enableSelfServiceBridging: false
  disableReadReceipts: false
  disableJoinLeaveNotifications: false
  disableInviteNotifications: false
  determineCodeLanguage: true
  adminMxid: '@hunter:hunterwittenborn.com'
  invalidTokenMessage: 'Your Discord bot token seems to be invalid, and the bridge cannot function. Please update it in your bridge settings and restart the bridge'
auth:
  clientID: "{{ matrix_discord_client_id }}"
  botToken: "{{ matrix_discord_bot_token }}"
  usePrivilegedIntents: true
logging:
  console: "warn" #silly, verbose, info, http, warn, error, silent
  lineDateFormat: "MMM-D HH:mm:ss.SSS" # This is in moment.js format
  files:
    - file: "debug.log"
      disable:
        - "PresenceHandler" # Will not capture presence logging
    - file: "warn.log" # Will capture warnings
      level: "warn"
    - file: "botlogs.log" # Will capture logs from DiscordBot
      level: "info"
      enable:
        - "DiscordBot"
database:
  filename: "discord.db"
  # connString: "postgresql://user:password@localhost/database_name"
room:
  defaultVisibility: "public"
channel:
    namePattern: "[Discord] :guild :name"
    deleteOptions:
       disableMessaging: false
       unsetRoomAlias: true
       unlistFromDirectory: true
       setInviteOnly: true
       ghostsLeave: true
limits:
    roomGhostJoinDelay: 6000
    discordSendDelay: 1500
ghosts:
    nickPattern: ":nick"
    usernamePattern: ":username#:tag"
metrics:
    enable: false
    port: 9001
    host: "127.0.0.1"

registration

as_token: "{{ matrix_discord_as_token }}"
hs_token: "{{ matrix_discord_hs_token }}"
id: discord-bridge
namespaces:
  aliases:
    - exclusive: true
      regex: '#_discord_.*:hunterwittenborn.com'
  rooms: []
  users:
    - exclusive: true
      regex: '@_discord_.*:hunterwittenborn.com'
protocols:
  - discord
rate_limited: false
sender_localpart: discord
url: 'http://matrix-discord:9005'
hwittenborn commented 1 year ago

My server and bridge instance is running in a Docker setup btw, that's why things like http://matrix-discord are present.

Also not sure if this issue is related to https://github.com/matrix-org/matrix-appservice-discord/issues/721 or not, but at the least this issue has more information, and I don't recall getting this same error when previously attempting to use the bridge.

hwittenborn commented 1 year ago

Looks like I just had to create the bot user, everything's working fine now.

iameli commented 1 year ago

@hwittenborn How does one create the bot user? Hitting the same problem.