Rhymen / go-whatsapp

WhatsApp Web API
MIT License
2.07k stars 492 forks source link

Panic error #551

Closed danielspk closed 3 years ago

danielspk commented 3 years ago

Hello, after more than 100 hours of successful execution I get the following panic:

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

goroutine 69753 [running]:
github.com/Rhymen/go-whatsapp.(*Conn).Disconnect(0xc0000e1500, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    github.com/Rhymen/go-whatsapp@v0.1.2-0.20210331105008-20ff81390fcd/conn.go:240 +0x96
github.com/Rhymen/go-whatsapp.(*Conn).connect.func2(0x3e8, 0x0, 0x0, 0x0, 0x0)
    github.com/Rhymen/go-whatsapp@v0.1.2-0.20210331105008-20ff81390fcd/conn.go:207 +0x110
github.com/gorilla/websocket.(*Conn).advanceFrame(0xc0000fc6e0, 0x0, 0x0, 0xc000607798)
    github.com/gorilla/websocket@v1.4.2/conn.go:945 +0x348
github.com/gorilla/websocket.(*Conn).NextReader(0xc0000fc6e0, 0xc0004608c0, 0x7f61008af2b8, 0xc0004608c0, 0x44ee56, 0xfae540)
    github.com/gorilla/websocket@v1.4.2/conn.go:980 +0x8f
github.com/Rhymen/go-whatsapp.(*Conn).readPump.func2(0xc0000e1500, 0xc000512160, 0xc000491500, 0xc0004914e0, 0xc000089020)
    github.com/Rhymen/go-whatsapp@v0.1.2-0.20210331105008-20ff81390fcd/read.go:33 +0x53
created by github.com/Rhymen/go-whatsapp.(*Conn).readPump
    github.com/Rhymen/go-whatsapp@v0.1.2-0.20210331105008-20ff81390fcd/read.go:31 +0x11c

Any idea?

beshoo commented 3 years ago

As I can see the panic start on //github.com/Rhymen/go-whatsapp@v0.1.2-0.20210331105008-20ff81390fcd/conn.go:240 err := wac.ws.conn.Close() But I can not understand how com wac.ws.conn is nil.

How can I reproduce this?

danielspk commented 3 years ago

Try to reproduce the panic without success. It occurred unexpectedly without any handlers being called according to the application logs.

Will this be related to a gorilla/websocket fix?

beshoo commented 3 years ago

Well, I tried also, Anyway... it is normal to have such cases, you need to set a service to check if go-whatsapp is working or not, if not, just restart the service.

victormedranop commented 3 years ago

Just use SYSTEMCTL, works for me. http://maratgaliev.com/go-service/

danielspk commented 3 years ago

Thanks