Fix more connection bugs

This commit is contained in:
Tulir Asokan 2021-02-25 13:49:28 +02:00
parent 2292c874d6
commit 1c28fbb49b
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.4
)
replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.4.0-rc.2.0.20210224154252-20161c37b47d
replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.4.0-rc.2.0.20210225114646-8538575a439d

2
go.sum
View file

@ -303,6 +303,8 @@ github.com/tulir/go-whatsapp v0.4.0-rc.2 h1:fYTC2IFQhL5j/3JyRnlp6PTYmSEnbSrPQgmD
github.com/tulir/go-whatsapp v0.4.0-rc.2/go.mod h1:rwwuTh1bKqhgrRvOBAr8hDqtuz8Cc1Quqw/0BeXb+/E=
github.com/tulir/go-whatsapp v0.4.0-rc.2.0.20210224154252-20161c37b47d h1:oxxlITnhw42ZWLB7GbLvHVMHHaKkWFDpk81t/bSwjko=
github.com/tulir/go-whatsapp v0.4.0-rc.2.0.20210224154252-20161c37b47d/go.mod h1:rwwuTh1bKqhgrRvOBAr8hDqtuz8Cc1Quqw/0BeXb+/E=
github.com/tulir/go-whatsapp v0.4.0-rc.2.0.20210225114646-8538575a439d h1:qvuNKXOolDmchhccwj4NyCD7vwXwc8l9Quwuxfx0oDk=
github.com/tulir/go-whatsapp v0.4.0-rc.2.0.20210225114646-8538575a439d/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

@ -837,6 +837,10 @@ func (user *User) HandleError(err error) {
}
go user.tryReconnect(fmt.Sprintf("Your WhatsApp connection was closed with websocket status code %d", closed.Code))
} else if failed, ok := err.(*whatsapp.ErrConnectionFailed); ok {
disconnectErr := user.Conn.Disconnect()
if disconnectErr != nil {
user.log.Warnln("Failed to disconnect after connection fail:", disconnectErr)
}
user.bridge.Metrics.TrackDisconnection(user.MXID)
user.ConnectionErrors++
go user.tryReconnect(fmt.Sprintf("Your WhatsApp connection failed: %v", failed.Err))