42wim / matterbridge

bridge between mattermost, IRC, gitter, xmpp, slack, discord, telegram, rocketchat, twitch, ssh-chat, zulip, whatsapp, keybase, matrix, microsoft teams, nextcloud, mumble, vk and more with REST API (mattermost not required!)
Apache License 2.0
6.6k stars 615 forks source link

Whatsapp QR Code Authentification not working #1949

Closed FaserF closed 1 year ago

FaserF commented 1 year ago

Describe the bug I can scan the QR Code, but get an error on my whatsapp phone saying "Can't link new devices at this time - Try again later". But when adding a new web.whatsapp.com session it works fine without any issue.

To Reproduce Initialize a Whatsapp Authentification via QR Code.

Expected behavior The QR Code Authentification to work

Screenshots/debug logs

time="2023-01-25T10:04:55+01:00" level=info msg="QR channel result: timeout" prefix=whatsapp
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x19702a2]
goroutine 1 [running]:
github.com/42wim/matterbridge/bridge/whatsappmulti.(*Bwhatsapp).Connect(0xc0000168c0)
    /matterbridge-1.25.2/bridge/whatsappmulti/whatsapp.go:118 +0x622
github.com/42wim/matterbridge/gateway.(*Router).Start(0xc00032e5a0)
    /matterbridge-1.25.2/gateway/router.go:76 +0x35f
main.main()
    /matterbridge-1.25.2/matterbridge.go:65 +0x39e
time="2023-01-25T10:04:57+01:00" level=info msg="WhatsApp connection successful" prefix=whatsapp

Environment (please complete the following information):

Additional context

42wim commented 1 year ago

@FaserF can you try current master?

webmeister commented 1 year ago

This seems to be broken in a slightly different way with the current master/v1.26.0. Starting with scanning the QR code:

00:00:24.328 [Client INFO] Successfully paired ...@s.whatsapp.net
time="00:00:24" level=info msg="QR channel result: success" prefix=whatsapp
time="00:00:25" level=info msg="WhatsApp connection successful" prefix=whatsapp
time="00:00:25" level=info msg="Getting user avatars.." prefix=whatsapp
time="00:00:25" level=info msg="Finished getting avatars.." prefix=whatsapp
time="00:00:25" level=info msg="whatsapp.bridge: joining ...@g.us (ID: ...@g.uswhatsapp.bridge)" prefix=whatsapp
00:00:25.802 [Client INFO] Successfully authenticated
time="00:00:26" level=info msg="Gateway(s) started succesfully. Now relaying messages" prefix=main

WhatsApp still says "Logging in..."

00:00:43.000 [Client INFO] Uploading 50 new prekeys to server

WhatsApp says "account is not allowed to use WhatsApp due to spam".

00:00:51.291 [Client WARN] Received stream end frame
00:00:51.296 [Client WARN] Got 503 stream error, assuming automatic reconnect will handle it
00:00:51.485 [Client/Socket ERROR] Error reading from websocket: websocket: close 1006 (abnormal closure): unexpected EOF
00:00:54.365 [Client INFO] Got 403: primary device was logged out connect failure, sending LoggedOut event and deleting session
00:00:54.480 [Client/Socket ERROR] Error reading from websocket: websocket: close 1006 (abnormal closure): unexpected EOF
00:00:56.299 [Client ERROR] Failed to download history sync data: failed to refresh media connections: failed to query media connections: websocket disconnected before info query returned response
00:00:56.301 [Client ERROR] Failed to do initial fetch of app state regular_low: failed to fetch app state regular_low patches: websocket disconnected before info query returned response

Tried it two times, account got blocked on the second attempt. Had them unblock it, tried it once more to collect the log above, now blocked again. Always tried it with v1.26.0, so I'm not sure whether the old version is affected in the same way.

This was not a completely new setup, but an existing matterbridge installation, that had to be linked to WhatsApp again, since WhatsApp got reinstalled on a new device.

FaserF commented 1 year ago

Tried it and now it is different. On the first try I got the same issue. Tried to scan it then a second time and then it worked again.