diff --git a/gateway/gateway_impl.go b/gateway/gateway_impl.go index 4d1169d6..3a70f46b 100644 --- a/gateway/gateway_impl.go +++ b/gateway/gateway_impl.go @@ -146,6 +146,9 @@ func (g *gatewayImpl) open(ctx context.Context) error { g.Close(closeCtx) return ctx.Err() case err = <-readyChan: + closeCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + g.Close(closeCtx) if err != nil { return fmt.Errorf("failed to open gateway connection: %w", err) }