Autoreconnect if keepalive ping throws error

This commit is contained in:
Tulir Asokan 2021-02-23 17:36:38 +02:00
parent 2918e7f89e
commit a5d60bf87d
3 changed files with 7 additions and 1 deletions

2
go.mod
View file

@ -16,4 +16,4 @@ require (
maunium.net/go/mautrix v0.8.3
)
replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.4.0-rc.1.0.20210223140805-2de4c4c5473f
replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.4.0-rc.1.0.20210223153547-62454c3af2c8

2
go.sum
View file

@ -295,6 +295,8 @@ github.com/tulir/go-whatsapp v0.4.0-rc.1.0.20210222222539-7472d76c0509 h1:F5iqT6
github.com/tulir/go-whatsapp v0.4.0-rc.1.0.20210222222539-7472d76c0509/go.mod h1:rwwuTh1bKqhgrRvOBAr8hDqtuz8Cc1Quqw/0BeXb+/E=
github.com/tulir/go-whatsapp v0.4.0-rc.1.0.20210223140805-2de4c4c5473f h1:7GPYeq8t3TZsKIEaeehi/Tf/mYhbiX0wzAuRH+Wy7Xs=
github.com/tulir/go-whatsapp v0.4.0-rc.1.0.20210223140805-2de4c4c5473f/go.mod h1:rwwuTh1bKqhgrRvOBAr8hDqtuz8Cc1Quqw/0BeXb+/E=
github.com/tulir/go-whatsapp v0.4.0-rc.1.0.20210223153547-62454c3af2c8 h1:WVZyCGqywD7ss+soR35mBPim3OWrgaJTjqQHEvhoJRg=
github.com/tulir/go-whatsapp v0.4.0-rc.1.0.20210223153547-62454c3af2c8/go.mod h1:rwwuTh1bKqhgrRvOBAr8hDqtuz8Cc1Quqw/0BeXb+/E=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=

View file

@ -840,6 +840,10 @@ func (user *User) HandleError(err error) {
user.bridge.Metrics.TrackDisconnection(user.MXID)
user.ConnectionErrors++
go user.tryReconnect(fmt.Sprintf("Your WhatsApp connection failed: %v", failed.Err))
} else if err == whatsapp.ErrPingFalse {
user.bridge.Metrics.TrackDisconnection(user.MXID)
user.ConnectionErrors++
go user.tryReconnect(fmt.Sprintf("Your WhatsApp connection failed: %v", err))
}
// Otherwise unknown error, probably mostly harmless
}