types: exit ping worker when error is happened

This commit is contained in:
c9s 2023-08-02 14:07:35 +08:00
parent 04da8fded7
commit e61db95bd8
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -274,6 +274,7 @@ func (s *StandardStream) ping(ctx context.Context, conn *websocket.Conn, cancel
if err := conn.WriteControl(websocket.PingMessage, nil, time.Now().Add(writeTimeout)); err != nil {
log.WithError(err).Error("ping error", err)
s.Reconnect()
return
}
}
}
@ -306,6 +307,7 @@ func (s *StandardStream) Connect(ctx context.Context) error {
}
// start one re-connector goroutine with the base context
// reconnector goroutine does not exit when the connection is closed
go s.reconnector(ctx)
s.EmitStart()