diff --git a/client/grpcutil/grpcutil.go b/client/grpcutil/grpcutil.go index 464fc3c19fa2..50bf81da2586 100644 --- a/client/grpcutil/grpcutil.go +++ b/client/grpcutil/grpcutil.go @@ -22,6 +22,7 @@ import ( "github.com/tikv/pd/client/errs" "google.golang.org/grpc" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/metadata" ) @@ -42,7 +43,7 @@ const ForwardMetadataKey = "pd-forwarded-host" // ctx will be noop. Users should call ClientConn.Close to terminate all the // pending operations after this function returns. func GetClientConn(ctx context.Context, addr string, tlsCfg *tls.Config, do ...grpc.DialOption) (*grpc.ClientConn, error) { - opt := grpc.WithInsecure() //nolint + opt := grpc.WithTransportCredentials(insecure.NewCredentials()) if tlsCfg != nil { creds := credentials.NewTLS(tlsCfg) opt = grpc.WithTransportCredentials(creds) diff --git a/server/region_syncer/client_test.go b/server/region_syncer/client_test.go index 80185e86f941..3e82dea33245 100644 --- a/server/region_syncer/client_test.go +++ b/server/region_syncer/client_test.go @@ -71,7 +71,7 @@ func TestErrorCode(t *testing.T) { } ctx, cancel := context.WithCancel(context.TODO()) rc := NewRegionSyncer(server) - conn, err := grpcutil.GetClientConn(ctx, "127.0.0.1", nil) + conn, err := grpcutil.GetClientConn(ctx, "http://127.0.0.1", nil) re.NoError(err) cancel() _, err = rc.syncRegion(ctx, conn)