rsms / gotalk

Async peer communication protocol & library
MIT License
1.2k stars 76 forks source link

Heartbeat panics when connection is lost #15

Open berk-can opened 3 years ago

berk-can commented 3 years ago

Hi there, I am using gotalk with linux devices and we sometimes reboot these devices, and at one time we encountered an error with panic in app

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

goroutine 3183863 [running]:
github.com/rsms/gotalk.(*Sock).SendHeartbeat(0xc007e9d140, 0xc03d834c1b, 0xc001cd0dd0, 0x10, 0x10, 0x0, 0x0)
        /Users/berkcan/go/pkg/mod/github.com/rsms/gotalk@v1.2.1/sock.go:662 +0xd2
github.com/rsms/gotalk.(*Sock).sendHeartbeats(0xc007e9d140, 0xc0050b6720)
        /Users/berkcan/go/pkg/mod/github.com/rsms/gotalk@v1.2.1/sock.go:643 +0xb5
created by github.com/rsms/gotalk.(*Sock).Read
        /Users/berkcan/go/pkg/mod/github.com/rsms/gotalk@v1.2.1/sock.go:700 +0x8c5

Is there a way to recover from panic