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

Bridge panics after a few hours #36

Closed vavrusa closed 5 years ago

vavrusa commented 5 years ago

There's several different panics after running it for a few hours:

panic: repeated read on failed websocket connection

goroutine 46 [running]:
github.com/gorilla/websocket.(*Conn).NextReader(0xc0000d4000, 0xf70de0, 0xc000281312, 0x2, 0xc00028a000, 0xc000186900)
        /go/pkg/mod/github.com/gorilla/websocket@v1.4.0/conn.go:967 +0x356
github.com/gorilla/websocket.(*Conn).ReadMessage(0xc0000d4000, 0xa15100, 0xc00050d5b0, 0x1, 0x1, 0xb57dc0, 0xc00050d5b0)
        /go/pkg/mod/github.com/gorilla/websocket@v1.4.0/conn.go:1028 +0x2f
github.com/Rhymen/go-whatsapp.(*Conn).readPump(0xc00015a270)
        /go/pkg/mod/github.com/!rhymen/go-whatsapp@v0.0.0-20190208090600-c1173899de99/conn.go:272 +0x73
created by github.com/Rhymen/go-whatsapp.NewConn
        /go/pkg/mod/github.com/!rhymen/go-whatsapp@v0.0.0-20190208090600-c1173899de99/conn.go:129 +0x1ff
[Feb 25, 2019 17:27:51] [Command handler/DEBUG] Importing all contacts of &{0xc000089040 0xc0004340e0 0xc0001620a0 0xc0000894a0 true true}
panic: runtime error: slice bounds out of range

goroutine 51 [running]:
github.com/Rhymen/go-whatsapp.(*Conn).decryptBinaryMessage(0xc0001955f0, 0xc000248260, 0xe, 0x10, 0xe, 0x10, 0x800a)
        /go/pkg/mod/github.com/!rhymen/go-whatsapp@v0.0.0-20190208090600-c1173899de99/conn.go:371 +0x3cc
github.com/Rhymen/go-whatsapp.(*Conn).query(0xc0001955f0, 0xac1480, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /go/pkg/mod/github.com/!rhymen/go-whatsapp@v0.0.0-20190208090600-c1173899de99/contact.go:204 +0x3b0
github.com/Rhymen/go-whatsapp.(*Conn).Contacts(0xc0001955f0, 0xc000434760, 0x2, 0x2)
        /go/pkg/mod/github.com/!rhymen/go-whatsapp@v0.0.0-20190208090600-c1173899de99/contact.go:128 +0x76
main.(*CommandHandler).CommandSync(0xc00018b400, 0xc0000b7ef8)
        /go/src/github.com/mautrix-whatsapp/commands.go:160 +0x112
main.(*CommandHandler).Handle(0xc00018b400, 0xc0002ee720, 0x1f, 0xc00017b860, 0xc000024ef8, 0x4)
        /go/src/github.com/mautrix-whatsapp/commands.go:87 +0x2f8
main.(*MatrixHandler).HandleMessage(0xc00017b290, 0xc00008c480)
        /go/src/github.com/mautrix-whatsapp/matrix.go:161 +0x210
main.(*MatrixHandler).HandleMessage-fm(0xc00008c480)
        /go/src/github.com/mautrix-whatsapp/matrix.go:43 +0x34
created by maunium.net/go/mautrix-appservice.(*EventProcessor).Start
        /go/pkg/mod/maunium.net/go/mautrix-appservice@v0.1.0-alpha.3/eventprocessor.go:62 +0x55

The installed version is 485acf6de654b8fb70007876c074fb004eb9717b

vavrusa commented 5 years ago

There's another one:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x7398ad]

goroutine 64 [running]:
github.com/Rhymen/go-whatsapp.(*Conn).writeBinary(0xc00018b860, 0xabe91b, 0x5, 0xc000656000, 0x0, 0x0, 0x800a, 0xc00024aac0, 0xe, 0xc000304f00, ...)
        /go/pkg/mod/github.com/!rhymen/go-whatsapp@v0.0.0-20190208090600-c1173899de99/conn.go:241 +0x9d
github.com/Rhymen/go-whatsapp.(*Conn).query(0xc00018b860, 0xac1480, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /go/pkg/mod/github.com/!rhymen/go-whatsapp@v0.0.0-20190208090600-c1173899de99/contact.go:199 +0x321
github.com/Rhymen/go-whatsapp.(*Conn).Contacts(0xc00018b860, 0xc000262ce0, 0x2, 0x2)
        /go/pkg/mod/github.com/!rhymen/go-whatsapp@v0.0.0-20190208090600-c1173899de99/contact.go:128 +0x76
main.(*CommandHandler).CommandSync(0xc000183680, 0xc0001f5ef8)
        /go/src/github.com/mautrix-whatsapp/commands.go:160 +0x112
main.(*CommandHandler).Handle(0xc000183680, 0xc0002f0680, 0x1f, 0xc00017b980, 0xc00024a820, 0x4)
        /go/src/github.com/mautrix-whatsapp/commands.go:87 +0x2f8
main.(*MatrixHandler).HandleMessage(0xc00017b3b0, 0xc00008c900)
        /go/src/github.com/mautrix-whatsapp/matrix.go:161 +0x210
main.(*MatrixHandler).HandleMessage-fm(0xc00008c900)
        /go/src/github.com/mautrix-whatsapp/matrix.go:43 +0x34
created by maunium.net/go/mautrix-appservice.(*EventProcessor).Start
        /go/pkg/mod/maunium.net/go/mautrix-appservice@v0.1.0-alpha.3/eventprocessor.go:62 +0x55
enannos commented 5 years ago

Hi,

I have a similar problem. The bridge panics and freezes after a couple of minutes. Here is an output:

[Feb 26, 2019 20:20:51] [User/@XXXXX.XXXXX.XXXXX/ERROR] WhatsApp error: unexpected websocket close: websocket: close 1006 (abnormal closure): unexpected EOF

tulir commented 5 years ago

@enannos that output is #35

tulir commented 5 years ago

Some or all of these might be fixed with the recent go-whatsapp updates.

vmario89 commented 5 years ago

hi. i just made some temporary dirty workaround on Ubuntu using cronjob

SHELL=/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 0 /1 root /bin/systemctl stop mautrix-whatsapp.service && /bin/systemctl start mautrix-whatsapp.service -> restart once per hour

vmario89 commented 5 years ago

The issue still occures with latest commit

socket close: websocket: close 1000 (normal) Mai 16 10:10:51 h2606131.stratoserver.net mautrix-whatsapp[4112]: [May 16, 2019 10:10:51] [User/@vmario89:matrix.fablabchemnitz.de/ERROR] WhatsApp error: unexpected websocket close: websocket: close 1000 (normal) Mai 16 10:10:52 h2606131.stratoserver.net mautrix-whatsapp[4112]: [May 16, 2019 10:10:52] [User/@vmario89:matrix.fablabchemnitz.de/ERROR] WhatsApp error: unexpected websocket close: websocket: close 1000 (normal) Mai 16 10:10:53 h2606131.stratoserver.net mautrix-whatsapp[4112]: [May 16, 2019 10:10:53] [User/@vmario89:matrix.fablabchemnitz.de/ERROR] WhatsApp error: unexpected websocket close: websocket: close 1000 (normal) Mai 16 10:10:54 h2606131.stratoserver.net mautrix-whatsapp[4112]: panic: repeated read on failed websocket connection Mai 16 10:10:54 h2606131.stratoserver.net mautrix-whatsapp[4112]: goroutine 24 [running]: Mai 16 10:10:54 h2606131.stratoserver.net mautrix-whatsapp[4112]: github.com/gorilla/websocket.(*Conn).NextReader(0xc00032c2c0, 0x1170f80, 0xc004d61312, 0x2, 0xc004d6c000, 0xc000001e00)

regards, Mario

tulir commented 5 years ago

That doesn't look like the latest version. The websocket close error says something more like WhatsApp error: server closed connection,code: 1000,text: in the latest version.

Are you sure you updated properly?

vmario89 commented 5 years ago

yep i forgot to run "go build". I tried to clone the repo again but now i cannot compile

  1. git clone https://github.com/tulir/mautrix-whatsapp.git
  2. go build

grafik

i have no knowledge about go.mod and dependencies :(

tulir commented 5 years ago

Sorry, committed the development replace directives in go.mod again. Try with the latest commit

vmario89 commented 5 years ago

hey. thanks for the quick nightly reply 👍 i tried again now it proceeds with

grafik

but it does not generate the final built file to run. "mautrix-whatsapp" is missing

tulir commented 5 years ago

Your Go installation seems broken. If you install Go by downloading from https://golang.org/dl/, make sure you remove the old files before unpacking the new ones. Otherwise files that were removed in the new release will stick around and cause errors like that.

vmario89 commented 5 years ago

that was the fix :D problem of the problem. i updated go a lot in the past. but first time some error occures :) but now it seems fine. will check it out a while and will give you some feedback again. thanks for your help and all the recent updates!

regards, Mario

anoadragon453 commented 5 years ago

Seems like this issue can be closed? I've been running the bridge for a couple weeks now with no crashes.