Merge pull request #1266 from c9s/c9s/exit-ping-worker-when-err

FIX: types: exit ping worker when error is happened
This commit is contained in:
c9s 2023-08-02 14:20:20 +08:00 committed by GitHub
commit fe0a630fa8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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()