mautrix / whatsapp

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

Docker container fails to connect #238

Closed danielfomin96 closed 4 years ago

danielfomin96 commented 4 years ago

I am getting the following error when connecting using docker:

 [ERROR] Failed to connect to homeserver: failed to GET /_matrix/client/r0/account/whoami: M_FORBIDDEN (HTTP 403): Application service has not registered this user. Retrying in 10 seconds...

Could you please guide to where the problem might be? Should I maybe take care of some settings in synapse?

Only modifications of homeserver.yaml:

[...]
app_service_config_files:
  - /bridges/whatsapp/data/registration.yaml
[...]

config.yaml:

homeserver:
  address: https://matrix.example.com
  domain: matrix.example.com
  asmux: false
appservice:
  address: http://localhost:29318
  hostname: 0.0.0.0
  port: 29318
  database:
    type: sqlite3
    uri: mautrix-whatsapp.db
    max_open_conns: 20
    max_idle_conns: 2
  provisioning:
    prefix: /_matrix/provision/v1
    shared_secret: my_random_secret_generated_from_synapse
  id: whatsapp
  bot:
    username: whatsappbot
    displayname: WhatsApp bridge bot
    avatar: mxc://maunium.net/NeXNQarUbrlYBiPCpprYsRqr
  as_token: secret_token1
  hs_token: secret_token2
metrics:
  enabled: false
  listen: 127.0.0.1:8001
whatsapp:
  os_name: Mautrix-WhatsApp bridge
  browser_name: mx-wa
bridge:
  username_template: whatsapp_{{.}}
  displayname_template: '{{if .Notify}}{{.Notify}}{{else}}{{.Jid}}{{end}} (WA)'
  community_template: whatsapp_{{.Localpart}}={{.Server}}
  connection_timeout: 20
  fetch_message_on_timeout: false
  delivery_receipts: false
  login_qr_regen_count: 2
  max_connection_attempts: 3
  connection_retry_delay: -1
  report_connection_retry: true
  chat_list_wait: 30
  portal_sync_wait: 600
  user_message_buffer: 1024
  portal_message_buffer: 128
  call_notices:
    start: true
    end: true
  initial_chat_sync_count: 10
  initial_history_fill_count: 20
  initial_history_disable_notifications: false
  recovery_chat_sync_count: -1
  recovery_history_backfill: true
  sync_max_chat_age: 259200
  sync_with_custom_puppets: true
  sync_direct_chat_list: false
  default_bridge_receipts: true
  default_bridge_presence: true
  login_shared_secret: ""
  invite_own_puppet_for_backfilling: true
  private_chat_portal_meta: false
  resend_bridge_info: false
  whatsapp_thumbnail: false
  allow_user_invite: false
  command_prefix: '!wa'
  encryption:
    allow: false
    default: false
    key_sharing:
      allow: false
      require_cross_signing: false
      require_verification: true
  permissions
[...]

The logs for synapse also show that the application is registered:

 synapse.config.appservice - 87 - INFO - None - Loaded application service: ApplicationService: {'token': '<redacted>', 'url': 'http://localhost:29318', 'hs_token': '<redacted>', 'sender': '@redacted_pass:matrix.example.com', 'server_name': 'matrix.example.com', 'namespaces': {'users': [{'regex': re.compile('^@whatsapp_[0-9]+:matrix.example.com$'), 'exclusive': True}, {'regex': re.compile('^@whatsappbot:matrix.example.com$'), 'exclusive': True}], 'aliases': [], 'rooms': []}, 'id': 'whatsapp', 'ip_range_whitelist': None, 'supports_ephemeral': False, 'protocols': set(), 'rate_limited': False}

'example.com' is used everywhere instead of my real domain name.

Thank you very much for this great project.

Haringstad commented 4 years ago
 [ERROR] Failed to connect to homeserver: failed to GET /_matrix/client/r0/account/whoami: M_FORBIDDEN (HTTP 403): Application service has not registered this user. Retrying in 10 seconds...

Yup, I have exactly the same issue.....

tulir commented 4 years ago

Setup issues should go to #whatsapp:maunium.net, github is for bug reports/feature requests (I really need to make some issue templates at some point)

tobymurray commented 3 years ago

Having also run into this, I missed that there appears to be relevant state in the database. You need to make sure that your config.yaml, registration.yaml and bridge database are all aligned. Practically speaking, this means if you change your config.yaml, delete your registration.yaml and bridge database (e.g. mautrix-whatsapp.db) then redo it all.