mautrix / whatsapp

A Matrix-WhatsApp puppeting bridge
https://maunium.net/go/mautrix-whatsapp
GNU Affero General Public License v3.0
1.25k stars 172 forks source link

bot will not respond in a docker-compose environment #60

Closed kreemer closed 5 years ago

kreemer commented 5 years ago

Setup: Docker-Compose file with synapse and traefik as load balancer.

version: '3.7'

services:
  synapse:
    image: docker.io/matrixdotorg/synapse:latest
    restart: unless-stopped
    environment:
      - SYNAPSE_SERVER_NAME=[DOMAIN]
      - SYNAPSE_REPORT_STATS=no
      - SYNAPSE_ENABLE_REGISTRATION=yes
      - SYNAPSE_LOG_LEVEL=INFO
      - SYNAPSE_NO_TLS=1
      - POSTGRES_DB=synapse
      - POSTGRES_USER=synapse
      - POSTGRES_HOST=sdb
      - POSTGRES_PASSWORD=changeme
    volumes:
      - ${CONFIG_DIR}/synapse/app:/data
    depends_on:
      - sdb
    ports:
      - 8008
    labels:
      - "traefik.enable=true"
      - "traefik.basic.frontend.rule=Host:[DOMAIN]"
      - "traefik.basic.port=8008"
      - "traefik.basic.protocol=http"

  whatsapp:
    image: tulir/mautrix-whatsapp
    restart: unless-stopped
    volumes:
      - ${CONFIG_DIR}/synapse/bridges/mautrix-whatsapp:/data
    ports:
      - 8080
    depends_on:
      - synapse

  sdb:
    image: docker.io/postgres:10-alpine
    environment:
      - POSTGRES_DB=synapse
      - POSTGRES_USER=synapse
      - POSTGRES_PASSWORD=changeme
    volumes:
      - ${CONFIG_DIR}/synapse/db:/var/lib/postgresql/data

I'm using following config file:

homeserver:
  address: http://synapse:8008
  domain: [DOMAIN]
appservice:
  address: http://whatsapp:8080
  hostname: 0.0.0.0
  port: 8080
  database:
    type: sqlite3
    uri: mautrix-whatsapp.db
  state_store_path: ./mx-state.json
  id: whatsapp
  bot:
    username: whatsappbot
    displayname: WhatsApp bridge bot
    avatar: mxc://maunium.net/NeXNQarUbrlYBiPCpprYsRqr
  as_token: [STRIPPED]
  hs_token: [STRIPPED]
bridge:
  username_template: whatsapp_{{.}}
  displayname_template: '{{if .Notify}}{{.Notify}}{{else}}{{.Jid}}{{end}} (WA)'
  command_prefix: '!wa'
  permissions:
    '@admin:example.com': 100
    example.com: 10
logging:
  directory: ./logs
  file_name_format: '{{.Date}}-{{.Index}}.log'
  file_date_format: "2006-01-02"
  file_mode: 384
  timestamp_format: Jan _2, 2006 15:04:05
  print_level: debug

The log file puts out a warning about the avatar, but nothing else:

Registration generated. Add the path to the registration to your Synapse config restart it, then start the bridge.                                                                            
Didn't find a registration file.
Generated one for you.
Copy that over to synapses app service directory.
[Mar 28, 2019 10:02:47] [DEBUG] Initializing state store
[Mar 28, 2019 10:02:47] [DEBUG] Initializing database
[Mar 28, 2019 10:02:47] [DEBUG] Initializing Matrix event processor
[Mar 28, 2019 10:02:47] [DEBUG] Initializing Matrix event handler
[Mar 28, 2019 10:02:47] [INFO] Bridge initialization complete, starting...
[Mar 28, 2019 10:02:47] [DEBUG] Starting application service HTTP server
[Mar 28, 2019 10:02:47] [DEBUG] Starting event processor
[Mar 28, 2019 10:02:47] [Matrix/INFO] Listening on 0.0.0.0:8080
[Mar 28, 2019 10:02:47] [INFO] Bridge started!
[Mar 28, 2019 10:02:47] [DEBUG] Updating bot profile
[Mar 28, 2019 10:02:47] [DEBUG] Starting users
[Mar 28, 2019 10:02:47] [WARN] Failed to update bot avatar: msg=Failed to PUT JSON to /_matrix/client/r0/profile/@whatsappbot:[DOMAIN]/avatar_url code=401 wrapped=M_UNKNOWN_TOKEN: Invalid macaroon passed.
[Mar 28, 2019 10:02:47] [WARN] Failed to update bot displayname: msg=Failed to PUT JSON to /_matrix/client/r0/profile/@whatsappbot:[DOMAIN]/displayname code=401 wrapped=M_UNKNOWN_TOKEN: Invalid macaroon passed.

In the webclient, the bot doesnt answer with the expected "This room has been registered as your bridge management/status room."

tulir commented 5 years ago

Are you sure you gave the registration file to synapse and restarted it?

kreemer commented 5 years ago

Hi

Thanks for the fast reply Indeed I've misunderstood point 4 in "Bridge Setup" on the following page: https://github.com/tulir/mautrix-whatsapp/wiki

It is better described here: https://github.com/tulir/mautrix-whatsapp/wiki/Bridge-setup

For future reference: the synapse docker container searches for all *.yaml files in the local directory "/data/appservices/". So the only thing I had to do is to copy the generated registration.yaml to this path in the container.

I'll close this issue