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.59k stars 614 forks source link

WhatsApp doesn't work until I restart it #2046

Open tuxmartin opened 1 year ago

tuxmartin commented 1 year ago

Describe the bug

I'm using Matterbrdige for Rocket.Chat <---> WhatsApp Business integration. After restarting Mattebridge, it works. But if no message was sent for some time, is stopped working. I don't know how much time. I tested it about 12 hours ago, and it worked. Now it was broken. It has happened to me several times.

Expected behavior It should work without fail :-)

Screenshots/debug logs I started Mattebrdige using matterbridge -debug. There is a log after the start without sending any message for all night:

Apr 23 22:52:57 example.net matterbridge[3656059]: time="2023-04-23T22:52:57+02:00" level=info msg="Connection succeeded" func=apiLogin file="/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230405213915-89b0d362d291/bridge/rocketchat/helpers.go:84" prefix=rocketchat
Apr 23 22:52:57 example.net matterbridge[3656059]: time="2023-04-23T22:52:57+02:00" level=info msg="rocketchat.test: joining matterbridge-test (ID: matterbridge-testrocketchat.test)" func=joinChannels file="/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230405213915-89b0d362d291/bridge/bridge.go:77" prefix=rocketchat
Apr 23 22:52:57 example.net matterbridge[3656059]: time="2023-04-23T22:52:57+02:00" level=debug msg="Choosing login/password based receiving" func=handleRocket file="/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230405213915-89b0d362d291/bridge/rocketchat/handlers.go:17" prefix=rocketchat
Apr 23 22:52:57 example.net matterbridge[3656059]: time="2023-04-23T22:52:57+02:00" level=info msg="Gateway(s) started succesfully. Now relaying messages" func=main file="/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230405213915-89b0d362d291/matterbridge.go:68" prefix=main
Apr 24 00:03:21 example.net matterbridge[3656059]: 00:03:21.008 [Client/Socket ERROR] Error reading from websocket: websocket: close 1006 (abnormal closure): unexpected EOF
Apr 24 00:03:21 example.net matterbridge[3656059]: 00:03:21.021 [Client/Socket ERROR] Error closing websocket: tls: failed to send closeNotify alert (but connection was closed anyway): write tcp 81.2.249.13:11292->31.13.84.51:443: write: connection reset by peer
Apr 24 00:03:21 example.net matterbridge[3656059]: 00:03:21.720 [Client INFO] Successfully authenticated

The messages did not go through. After restarting Matterbridge, it is ok. But for how long? Log after restart:

Apr 24 10:49:52 example.net matterbridge[3954390]: time="2023-04-24T10:49:52+02:00" level=debug msg="message models.Message{ID:"3udtwcynm4LFAtZWC", RoomID:"9tJ98w3kYg8fmBscM", Msg:"test nove verze matterbridge", EditedBy:"", Type:"", Groupable:false, EditedAt:<nil>, Timestamp:time.Date(2023, time.April, 24, 10, 49, 52, 538, time.Local), UpdatedAt:<nil>, Mentions:[]models.User(nil), User:(*models.User)(0xc00081c300), Attachments:[]models.Attachment{}, PostMessage:models.PostMessage{RoomID:"", Channel:"", Text:"", ParseUrls:false, Alias:"", Emoji:"", Avatar:"", Attachments:[]models.Attachment(nil)}}" func=handleRocketClient file="/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230405213915-89b0d362d291/bridge/rocketchat/handlers.go:70" prefix=rocketchat
Apr 24 10:49:52 example.net matterbridge[3954390]: time="2023-04-24T10:49:52+02:00" level=debug msg="<= Sending message from martin.test on rocketchat.test to gateway" func=handleRocket file="/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230405213915-89b0d362d291/bridge/rocketchat/handlers.go:22" prefix=rocketchat
Apr 24 10:49:52 example.net matterbridge[3954390]: time="2023-04-24T10:49:52+02:00" level=debug msg="<= Message is &config.Message{Text:"test nove verze matterbridge", Channel:"matterbridge-test", Username:"martin.test", UserID:"5ukxYHDeryxhYjL3f", Avatar:"", Account:"rocketchat.test", Event:"", Protocol:"", Gateway:"", ParentID:"", Timestamp:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), ID:"3udtwcynm4LFAtZWC", Extra:map[string][]interface {}{}}" func=handleRocket file="/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230405213915-89b0d362d291/bridge/rocketchat/handlers.go:23" prefix=rocketchat
Apr 24 10:49:52 example.net matterbridge[3954390]: time="2023-04-24T10:49:52+02:00" level=debug msg="=> Sending config.Message{Text:"test nove verze matterbridge", Channel:"matterbridge-test", Username:"martin.test", UserID:"5ukxYHDeryxhYjL3f", Avatar:"", Account:"rocketchat.test", Event:"", Protocol:"rocketchat", Gateway:"gateway1", ParentID:"", Timestamp:time.Date(2023, time.April, 24, 10, 49, 52, 750862484, time.Local), ID:"3udtwcynm4LFAtZWC", Extra:map[string][]interface {}{}} from rocketchat.test (matterbridge-test) to whatsapp.499xxxxxx (1203xxxxxxxxxxx597@g.us)" func=SendMessage file="/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230405213915-89b0d362d291/gateway/gateway.go:499" prefix=gateway
Apr 24 10:49:52 example.net matterbridge[3954390]: time="2023-04-24T10:49:52+02:00" level=debug msg="=> Receiving config.Message{Text:"test nove verze matterbridge", Channel:"1203xxxxxxxxxxx597@g.us", Username:"[rocketchat] <martin.test>: ", UserID:"5ukxYHDeryxhYjL3f", Avatar:"", Account:"rocketchat.test", Event:"", Protocol:"rocketchat", Gateway:"gateway1", ParentID:"", Timestamp:time.Date(2023, time.April, 24, 10, 49, 52, 750862484, time.Local), ID:"", Extra:map[string][]interface {}{}}" func=Send file="/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230405213915-89b0d362d291/bridge/whatsappmulti/whatsapp.go:376" prefix=whatsapp
Apr 24 10:49:53 example.net matterbridge[3954390]: time="2023-04-24T10:49:53+02:00" level=debug msg="mID whatsapp.499xxxxxx: 420499xxxxxx@s.whatsapp.net/3EB00BFDD744F010AEA7" func=SendMessage file="/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230405213915-89b0d362d291/gateway/gateway.go:518" prefix=gateway
Apr 24 10:49:53 example.net matterbridge[3954390]: time="2023-04-24T10:49:53+02:00" level=debug msg="=> Send from rocketchat.test (matterbridge-test) to whatsapp.499xxxxxx (1203xxxxxxxxxxx597@g.us) took 964.485442ms" func=func1 file="/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230405213915-89b0d362d291/gateway/gateway.go:508" prefix=gateway

Environment (please complete the following information):

Additional context

My config:

[whatsapp.499xxxxxx]
    Number="+4204499xxxxxx"
    SessionFile="/home/matterbridge/whatsapp-session-499xxxxxx.gob"
    RemoteNickFormat="[{PROTOCOL}] <{NICK}>: "
    Label="+420"
    QrOnWhiteTerminal=false

[rocketchat.test]
    Server="https://rc.test.eu/"
    Login="test@test.net"
    Password="123456789"
    PrefixMessagesWithNick=false
    RemoteNickFormat="[{PROTOCOL}] <{NICK}> "

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

    [[gateway.inout]]
    account = "whatsapp.499xxxxxx"
    channel = "1203xxxxxxxxxxxx597@g.us"

    [[gateway.inout]]
    account="rocketchat.test"
    channel="matterbridge-test"
shelomito12 commented 1 year ago

Same issue here

15:01:49.608 [Client WARN] Received stream end frame
15:01:49.608 [Client INFO] Got device removed stream error, sending LoggedOut event and deleting session
15:01:49.737 [Client/Socket ERROR] Error reading from websocket: websocket: close 1006 (abnormal closure): unexpected EOF
tuxmartin commented 1 year ago

Is there any workaround how can I fix it?

shelomito12 commented 1 year ago

Guys any updates on this? My services has been down for more then a month already and don't see any recent PR attempting a fix.

weskerty commented 12 months ago

delete session-48111222334.gob and log in again. Every time you restart the bot.

tuxmartin commented 12 months ago

@weskerty delete session-48111222334.gob and log in again. Every time you restart the bot.

It's not possible.

Here is description from the original problem:

After restarting Mattebridge, it works. But if no message was sent for some time, is stopped working.

It stopped working after some time. I cannot restart it for example every 8 hours and scan QR code again...