42wim/matterbridge

[whatsapp] unable to obtain the QR code

vitoyucepi opened this issue · 0 comments

Describe the bug
Matterbridge doesn't get the QR code, prints an error, and fails with an exception.

To Reproduce

[[gateway]]
name="gateway1"
enable=true

[[gateway.inout]]
account="whatsapp.wa1"
channel="48111222333-123455678999@g.us"

[whatsapp.wa1]
Number="+48111222333"
SessionFile="/var/matterbridge/whatsapp_48111222333.gob"

Expected behavior

  1. Matterbridge displays a QR code from whatsapp.
  2. Matterbridge doesn't throw a SIGSEGV exception.

Screenshots/debug logs

time="2023-10-16T15:33:31Z" level=info msg="Enabling debug logging." func=setupLogger file="matterbridge.go:104" prefix=main
time="2023-10-16T15:33:31Z" level=info msg="Running version 1.26.0 " func=main file="matterbridge.go:44" prefix=main
time="2023-10-16T15:33:31Z" level=info msg="Parsing gateway gateway1" func=Start file="gateway/router.go:66" prefix=router
time="2023-10-16T15:33:31Z" level=info msg="Starting bridge: whatsapp.wa1 " func=Start file="gateway/router.go:75" prefix=router
time="2023-10-16T15:33:31Z" level=debug msg="Connecting to WhatsApp.." func=Connect file="bridge/whatsappmulti/whatsapp.go:75" prefix=whatsapp
15:33:32.308 [Client ERROR] Client outdated (405) connect failure
time="2023-10-16T15:33:32Z" level=info msg="QR channel result: err-client-outdated" func=Connect file="bridge/whatsappmulti/whatsapp.go:100" prefix=whatsapp
15:33:32.308 [Client/Socket ERROR] Error reading from websocket: websocket: close 1006 (abnormal closure): unexpected EOF
time="2023-10-16T15:33:33Z" level=info msg="WhatsApp connection successful" func=Connect file="bridge/whatsappmulti/whatsapp.go:117" prefix=whatsapp
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x558f61dfbce2]

goroutine 1 [running]:
github.com/42wim/matterbridge/bridge/whatsappmulti.(*Bwhatsapp).Connect(0xc000467dc0)
 github.com/42wim/matterbridge/bridge/whatsappmulti/whatsapp.go:119 +0x622
github.com/42wim/matterbridge/gateway.(*Router).Start(0xc00032c690)
 github.com/42wim/matterbridge/gateway/router.go:76 +0x35f
main.main()
 github.com/42wim/matterbridge/matterbridge.go:65 +0x39e

Environment (please complete the following information):

Additional context
Everything works fine in 56e7bd0.
I used git bisect to find that it has worked since 08779c2.
Before building, I used the following script to correct the erroneous behavior.

go mod edit -replace \
  go.mau.fi/whatsmeow=go.mau.fi/whatsmeow@v0.0.0-20230306190159-5caded34a872
go mod download go.mau.fi/whatsmeow
go mod tidy
go mod vendor

56e7bd0 prints the same QR code multiple times and then fails with the exception.