Disconnect and reconnect automatically if post-login ping fails
This commit is contained in:
parent
31049cd4d5
commit
51f0be415b
14
user.go
14
user.go
@ -456,7 +456,19 @@ func (user *User) intPostLogin() {
|
|||||||
|
|
||||||
err := user.Conn.AdminTest()
|
err := user.Conn.AdminTest()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
user.sendMarkdownBridgeAlert("Post-connection ping failed: %v", err)
|
user.log.Errorfln("Post-connection ping failed: %v. Disconnecting and then reconnecting after a second", err)
|
||||||
|
sess, disconnectErr := user.Conn.Disconnect()
|
||||||
|
if disconnectErr != nil {
|
||||||
|
user.log.Warnln("Error while disconnecting after failed post-login ping:", disconnectErr)
|
||||||
|
} else {
|
||||||
|
user.Session = &sess
|
||||||
|
}
|
||||||
|
user.bridge.Metrics.TrackDisconnection(user.MXID)
|
||||||
|
go func() {
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
user.tryReconnect(fmt.Sprintf("Post-connection ping failed: %v", err))
|
||||||
|
}()
|
||||||
|
return
|
||||||
} else {
|
} else {
|
||||||
user.log.Debugln("Post-login ping OK")
|
user.log.Debugln("Post-login ping OK")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user