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

Synapse exception on talking to appservice #44

Closed kiliankoe closed 3 years ago

kiliankoe commented 5 years ago

Hi all,

I'm having some issues getting this set up 😕 To be fair this is the first time I've set up Synapse or any appservice.

Currently my Synapse is outputting the following in its logs. Specifically the last line is what I don't understand.

2019-03-10 05:23:58,510 - synapse.http.client - 265 - INFO - as-recoverer-whatsapp-6 - Sending request PUT http://mautrixwhatsapp:8080/transactions/1?access_token=<redacted>
2019-03-10 05:23:58,516 - synapse.http.client - 286 - INFO - as-recoverer-whatsapp-6 - Received response to PUT http://mautrixwhatsapp:8080/transactions/1?access_token=<redacted>: 200
2019-03-10 05:23:58,517 - synapse.appservice.api - 249 - WARNING - as-recoverer-whatsapp-6 - push_bulk to http://mautrixwhatsapp:8080/transactions/1 threw exception Expecting value: line 1 column 1 (char 0)

I put mautrix-whatsapp as another service in my docker-compose.yml for Synapse, the service is called mautrixwhatsapp, so http://mautrixwhatsapp:8080 should be accessible from Synapse. The services are in the same network and port 8080 is also set as the appservice port in my mautrix-whatsapp config:

appservice:
  address: http://mautrixwhatsapp:8080
  hostname: 0.0.0.0
  port: 8080

This is all the log output of mautrix-whatsapp I'm seeing.

[Mar 10, 2019 05:40:12] [DEBUG] Initializing state store
[Mar 10, 2019 05:40:12] [DEBUG] Initializing database
[Mar 10, 2019 05:40:12] [DEBUG] Initializing Matrix event processor
[Mar 10, 2019 05:40:12] [DEBUG] Initializing Matrix event handler
[Mar 10, 2019 05:40:12] [INFO] Bridge initialization complete, starting...
[Mar 10, 2019 05:40:12] [DEBUG] Starting application service HTTP server
[Mar 10, 2019 05:40:12] [DEBUG] Starting event processor
[Mar 10, 2019 05:40:12] [INFO] Bridge started!
[Mar 10, 2019 05:40:12] [Matrix/INFO] Listening on 0.0.0.0:8080
[Mar 10, 2019 05:40:12] [DEBUG] Updating bot profile
[Mar 10, 2019 05:40:12] [WARN] Failed to update bot avatar: msg=Failed to PUT JSON to /_matrix/client/r0/profile/@whatsappbot:matrix.org/avatar_url code=401 wrapped=M_UNKNOWN_TOKEN: Invalid macaroon passed.
[Mar 10, 2019 05:40:12] [WARN] Failed to update bot displayname: msg=Failed to PUT JSON to /_matrix/client/r0/profile/@whatsappbot:matrix.org/displayname code=401 wrapped=M_UNKNOWN_TOKEN: Invalid macaroon passed.

Any help whatsoever would be much appreciated!

ara4n commented 5 years ago

You probably need to add the AS to your synapse's config (homeserver.yaml). For mine, this looks like:

app_service_config_files:
    - /home/matrix/mautrix-whatsapp/registration.yaml
kiliankoe commented 5 years ago

Hey @ara4n, thanks for the suggestion. I double-checked, but the path to the registration.yml is specified in synapse's config and the file is definitely accessible at that path.

Konradrundfunk commented 4 years ago

I am experiencing the exact same issue. I am pretty sure that I pointed that correct.

killua-eu commented 4 years ago

Ok, so I'm affected by the same bug. What I did was i pinged localhost and got an ipv6 reply. So (on ubuntu) I did sysctl -w net.ipv6.conf.lo.disable_ipv6=1 which for some reason didn't help, but I didn't want to stop on a names problem. I reconfigured the bridge and registration from localhost:8080 to 127.0.0.1:8080 and got further. Upon reconnection i now get this:

Mar 28 21:46:23 kai02-matrix mautrix-whatsapp[7251]: [Mar 28, 2020 21:46:23] [DEBUG] Starting event processor
Mar 28 21:46:23 kai02-matrix mautrix-whatsapp[7251]: [Mar 28, 2020 21:46:23] [INFO] Bridge started!
Mar 28 21:46:23 kai02-matrix mautrix-whatsapp[7251]: [Mar 28, 2020 21:46:23] [DEBUG] Starting users
Mar 28 21:46:23 kai02-matrix mautrix-whatsapp[7251]: [Mar 28, 2020 21:46:23] [DEBUG] Updating bot profile
Mar 28 21:46:23 kai02-matrix mautrix-whatsapp[7251]: [Mar 28, 2020 21:46:23] [Matrix/INFO] Listening on 0.0.0.0:8080
Mar 28 21:46:23 kai02-matrix mautrix-whatsapp[7251]: [Mar 28, 2020 21:46:23] [DEBUG] Starting custom puppets
Mar 28 21:46:23 kai02-matrix mautrix-whatsapp[7251]: [Mar 28, 2020 21:46:23] [User/@pavel:matrix.industra.space/DEBUG] Connecting to WhatsApp
Mar 28 21:46:24 kai02-matrix mautrix-whatsapp[7251]: [Mar 28, 2020 21:46:24] [User/@pavel:matrix.industra.space/DEBUG] WhatsApp connection successful
Mar 28 21:46:44 kai02-matrix mautrix-whatsapp[7251]: [Mar 28, 2020 21:46:44] [User/@pavel:matrix.industra.space/ERROR] Failed to restore session: admin login errored: 419 (unknown error)
Mar 28 21:46:44 kai02-matrix mautrix-whatsapp[7251]: [Mar 28, 2020 21:46:44] [User/@pavel:matrix.industra.space/DEBUG] Disconnecting due to failed session restore...

any ideas on how to continue debugging this?

pavel@kai02-matrix:/opt/mautrix-whatsapp# http http://localhost:8080/transactions/2681 
HTTP/1.1 405 Method Not Allowed
Content-Length: 0
Date: Sat, 28 Mar 2020 21:46:38 GMT

... didnt help, I wouldnt know the method and payload required.

kugel- commented 4 years ago

I'm getting the same issue as @killua-eu

It worked with older versions of synapse (1.11) and mautrix-whatsapp (commit 260555b). With synapse 1.12.3 and commit e0aea74 I'm having this issue.

MurzNN commented 4 years ago

I got the same error Failed to restore session: admin login errored: 419 (unknown error) with Synapse 1.18 and last mautrix-whatsapp release 7c67fe75ebecb219b41a26c497cf92addd6f6627, will reverting to older commit not break databases?