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

Mautrix boot don't join room #193

Closed
Josue-T opened this issue May 30, 2020 · 3 comments
Closed

Mautrix boot don't join room #193

Josue-T opened this issue May 30, 2020 · 3 comments

Comments

@Josue-T
Copy link

Josue-T commented May 30, 2020

Hello,

I've some issue to finish the configuration for mautrix-whatsapp. Mautrix-whatsapp is running but the bot don't come in the room when I invite it.

Here is my configuration file config.yaml:

# Homeserver details.
homeserver:
    # The address that this appservice can use to connect to the homeserver.
    address: https://domain.tld
    # The domain of the homeserver (for MXIDs, etc).
    domain: domain.tld

# Application service host/registration related details.
# Changing these values requires regeneration of the registration.
appservice:
    # The address that the homeserver can use to connect to this appservice.
    address: http://localhost:29318

    # The hostname and port where this appservice should listen.
    hostname: 127.0.0.1
    port: 29318

    # Database config.
    database:
        # The database type. "sqlite3" and "postgres" are supported.
        type: postgres
        # The database URI.
        #   SQLite: File name is enough. https://github.com/mattn/go-sqlite3#connection-string
        #   Postgres: Connection string. For example, postgres://user:password@host/database?sslmode=disable
        uri: postgres://mautrix-whatsapp:pwd@localhost/mautrix-whatsapp?sslmode=disable
        # Maximum number of connections. Mostly relevant for Postgres.
        max_open_conns: 20
        max_idle_conns: 2

    # Settings for provisioning API
    provisioning:
        # Prefix for the provisioning API paths.
        prefix: /_matrix/provision/v1
        # Shared secret for authentication. If set to "disable", the provisioning API will be disabled.
        shared_secret: disable

    # The unique ID of this appservice.
    id: whatsapp
    # Appservice bot details.
    bot:
        # Username of the appservice bot.
        username: whatsappbot
        # Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty
        # to leave display name/avatar as-is.
        displayname: WhatsApp bridge bot
        avatar: mxc://maunium.net/NeXNQarUbrlYBiPCpprYsRqr

    # Authentication tokens for AS <-> HS communication. Autogenerated; do not modify.
    as_token: token
    hs_token: token

# Bridge config
bridge:
    # Localpart template of MXIDs for WhatsApp users.
    # {{.}} is replaced with the phone number of the WhatsApp user.
    username_template: whatsapp_{{.}}
    # Displayname template for WhatsApp users.
    # {{.Notify}} - nickname set by the WhatsApp user
    # {{.Jid}}    - phone number (international format)
    # The following variables are also available, but will cause problems on multi-user instances:
    # {{.Name}}   - display name from contact list
    # {{.Short}}  - short display name from contact list
    # To use multiple if's, you need to use: {{else if .Name}}, for example:
    # "{{if .Notify}}{{.Notify}}{{else if .Name}}{{.Name}}{{else}}{{.Jid}}{{end}} (WA)"
    displayname_template: "{{if .Notify}}{{.Notify}}{{else}}{{.Jid}}{{end}} (WA)"
    # Localpart template for per-user room grouping community IDs.
    # On startup, the bridge will try to create these communities, add all of the specific user's
    # portals to the community, and invite the Matrix user to it.
    # (Note that, by default, non-admins might not have your homeserver's permission to create
    #  communities.)
    # {{.Localpart}} is the MXID localpart and {{.Server}} is the MXID server part of the user.
    community_template: whatsapp_{{.Localpart}}={{.Server}}

    # WhatsApp connection timeout in seconds.
    connection_timeout: 20
    # If WhatsApp doesn't respond within connection_timeout, should the bridge try to fetch the message
    # to see if it was actually bridged? Use this if you have problems with sends timing out but actually
    # succeeding.
    fetch_message_on_timeout: false
    # Whether or not the bridge should send a read receipt from the bridge bot when a message has been
    # sent to WhatsApp. If fetch_message_on_timeout is enabled, a successful post-timeout fetch will
    # trigger a read receipt too.
    delivery_receipts: true
    # Number of times to regenerate QR code when logging in.
    # The regenerated QR code is sent as an edit and essentially multiplies the login timeout (20 seconds)
    login_qr_regen_count: 2
    # Maximum number of times to retry connecting on connection error.
    max_connection_attempts: 3
    # Number of seconds to wait between connection attempts.
    # Negative numbers are exponential backoff: -connection_retry_delay + 1 + 2^attempts
    connection_retry_delay: -1
    # Whether or not the bridge should send a notice to the user's management room when it retries connecting.
    # If false, it will only report when it stops retrying.
    report_connection_retry: true
    # Maximum number of seconds to wait for chats to be sent at startup.
    # If this is too low and you have lots of chats, it could cause backfilling to fail.
    chat_list_wait: 30
    # Maximum number of seconds to wait to sync portals before force unlocking message processing.
    # If this is too low and you have lots of chats, it could cause backfilling to fail.
    portal_sync_wait: 600

    # Whether or not to send call start/end notices to Matrix.
    call_notices:
        start: true
        end: true

    # Number of chats to sync for new users.
    initial_chat_sync_count: 10
    # Number of old messages to fill when creating new portal rooms.
    initial_history_fill_count: 20
    # Maximum number of chats to sync when recovering from downtime.
    # Set to -1 to sync all new chats during downtime.
    recovery_chat_sync_limit: -1
    # Whether or not to sync history when recovering from downtime.
    recovery_history_backfill: true
    # Maximum number of seconds since last message in chat to skip
    # syncing the chat in any case. This setting will take priority
    # over both recovery_chat_sync_limit and initial_chat_sync_count.
    # Default is 3 days = 259200 seconds
    sync_max_chat_age: 259200

    # Whether or not to sync with custom puppets to receive EDUs that
    # are not normally sent to appservices.
    sync_with_custom_puppets: true
    # Shared secret for https://github.com/devture/matrix-synapse-shared-secret-auth
    #
    # If set, custom puppets will be enabled automatically for local users
    # instead of users having to find an access token and run `login-matrix`
    # manually.
    login_shared_secret: null

    # Whether or not to invite own WhatsApp user's Matrix puppet into private
    # chat portals when backfilling if needed.
    # This always uses the default puppet instead of custom puppets due to
    # rate limits and timestamp massaging.
    invite_own_puppet_for_backfilling: true
    # Whether or not to explicitly set the avatar and room name for private
    # chat portal rooms. This can be useful if the previous field works fine,
    # but causes room avatar/name bugs.
    private_chat_portal_meta: false

    # Allow invite permission for user. User can invite any bots to room with whatsapp
    # users (private chat and groups)
    allow_user_invite: true

    # The prefix for commands. Only required in non-management rooms.
    command_prefix: "!wa"

    # End-to-bridge encryption support options. This requires login_shared_secret to be configured
    # in order to get a device for the bridge bot.
    #
    # Additionally, https://github.com/matrix-org/synapse/pull/5758 is required if using a normal
    # application service.
    encryption:
        # Allow encryption, work in group chat rooms with e2ee enabled
        allow: false
        # Default to encryption, force-enable encryption in all portals the bridge creates
        # This will cause the bridge bot to be in private chats for the encryption to work properly.
        # It is recommended to also set private_chat_portal_meta to true when using this.
        default: false

    # Permissions for using the bridge.
    # Permitted values:
    # relaybot - Talk through the relaybot (if enabled), no access otherwise
    #     user - Access to use the bridge to chat with a WhatsApp account.
    #    admin - User level and some additional administration tools
    # Permitted keys:
    #        * - All Matrix users
    #   domain - All users on that homeserver
    #     mxid - Specific user
    permissions:
        "domain.tld": relaybot
        "domain.tld": user
        "@user:domain.tld": admin

    relaybot:
        # Whether or not relaybot support is enabled.
        enabled: true
        # The management room for the bot. This is where all status notifications are posted and
        # in this room, you can use `!wa <command>` instead of `!wa relaybot <command>`. Omitting
        # the command prefix completely like in user management rooms is not possible.
        management: !abc:domain.tld
        # List of users to invite to all created rooms that include the relaybot.
        invites: []
        # The formats to use when sending messages to WhatsApp via the relaybot.
        message_formats:
            m.text: "<b>{{ .Sender.Displayname }}</b>: {{ .Message }}"
            m.notice: "<b>{{ .Sender.Displayname }}</b>: {{ .Message }}"
            m.emote: "* <b>{{ .Sender.Displayname }}</b> {{ .Message }}"
            m.file: "<b>{{ .Sender.Displayname }}</b> sent a file"
            m.image: "<b>{{ .Sender.Displayname }}</b> sent an image"
            m.audio: "<b>{{ .Sender.Displayname }}</b> sent an audio file"
            m.video: "<b>{{ .Sender.Displayname }}</b> sent a video"
            m.location: "<b>{{ .Sender.Displayname }}</b> sent a location"

# Logging config.
logging:
    # The directory for log files. Will be created if not found.
    directory: ./logs
    # Available variables: .Date for the file date and .Index for different log files on the same day.
    file_name_format: "{{.Date}}-{{.Index}}.log"
    # Date format for file names in the Go time format: https://golang.org/pkg/time/#pkg-constants
    file_date_format: 2006-01-02
    # Log file permissions.
    file_mode: 0600
    # Timestamp format for log entries in the Go time format.
    timestamp_format: Jan _2, 2006 15:04:05
    # Minimum severity for log messages.
    # Options: debug, info, warn, error, fatal
    print_level: debug

My registration file:

id: whatsapp
url: http://127.0.0.1:29318
as_token: same_token
hs_token: same_token
sender_localpart: whatsappbot
rate_limited: false
namespaces:
  users:
  - regex: ^@whatsapp_[0-9]+:domain.tld$
    exclusive: true

The log of mautrix-synapse:

[May 30, 2020 18:10:35] [DEBUG] Initializing database
[May 30, 2020 18:10:35] [DEBUG] Initializing state store
[May 30, 2020 18:10:35] [DEBUG] Initializing Matrix event processor
[May 30, 2020 18:10:35] [DEBUG] Initializing Matrix event handler
[May 30, 2020 18:10:35] [DEBUG] Bridge built with end-to-bridge encryption, but disabled in config
[May 30, 2020 18:10:35] [INFO] Bridge initialization complete, starting...
[May 30, 2020 18:10:35] [Database/Upgrade/INFO] Database currently on v15, latest: v15
[May 30, 2020 18:10:35] [DEBUG] Relaybot is enabled, but not logged in
[May 30, 2020 18:10:35] [DEBUG] Checking connection to homeserver
[May 30, 2020 18:10:36] [DEBUG] Starting application service HTTP server
[May 30, 2020 18:10:36] [DEBUG] Starting event processor
[May 30, 2020 18:10:36] [INFO] Bridge started!
[May 30, 2020 18:10:36] [DEBUG] Updating bot profile
[May 30, 2020 18:10:36] [DEBUG] Starting users
[May 30, 2020 18:10:36] [Matrix/INFO] Listening on 127.0.0.1:29318
[May 30, 2020 18:10:36] [DEBUG] Starting custom puppets

When I try to join invite the boot I got this in the synapse log:

2020-05-30 17:54:20,090 - synapse.storage.data_stores.main.events_worker - 630 - WARNING - notify_app_services-16- Room !XqBunHwQIXUiqCaoxq:matrix.org for event $143550163473031vyTLF:matrix.org is unknown
2020-05-30 17:54:20,092 - synapse.storage.data_stores.main.events_worker - 630 - WARNING - notify_app_services-16- Room !XqBunHwQIXUiqCaoxq:matrix.org for event $14194248451407xZVvE:matrix.org is unknown
2020-05-30 17:54:20,094 - synapse.storage.data_stores.main.events_worker - 630 - WARNING - notify_app_services-16- Room !XqBunHwQIXUiqCaoxq:matrix.org for event $1426624670851jPIbA:matrix.org is unknown
2020-05-30 17:54:20,097 - synapse.storage.data_stores.main.events_worker - 630 - WARNING - notify_app_services-16- Room !XqBunHwQIXUiqCaoxq:matrix.org for event $143983625614685edzmR:matrix.org is unknown
@Gredin67
Copy link

Gredin67 commented Jun 1, 2020

Hi @Josue-T
FYI I already packaged the bridge to work along your synapse package for Yunohost. You can have a look at https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh/blob/master/scripts/install#L265 to see what I had to modify from the template config file.

Btw I would like to have your feedback on my package (security,...), and get some tips on how to get the backup and restore script working. I mean the synapse database is used by the bridge. So the backup/restore of synapse and mautrix_whatsapp should somehow be synchronized.

@Josue-T
Copy link
Author

Josue-T commented Jun 1, 2020

Probably linked to matrix-org/synapse#7615.

@tulir
Copy link
Member

tulir commented Jun 25, 2020

Those errors don't seem related, it's probably just that you misconfigured something and synapse can't reach the appservice. Grepping for transactions in the synapse logs will show the relevant errors if that's the case.

@tulir tulir closed this as completed Jun 25, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants