{"record":{"id":"b944db8664a7d00e","repo":"hyperledger/fabric","slug":"connection-to-d-s-is-in-state-s","errorCode":null,"errorMessage":"connection to %d(%s) is in state %s","messagePattern":"connection to (.+?)\\((.+?)\\) is in state (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"orderer/common/cluster/comm.go","lineNumber":292,"sourceCode":"\t\tcert, err := x509.ParseCertificate(stub.ServerTLSCert)\n\t\tif err != nil {\n\t\t\tpemString := string(pem.EncodeToMemory(&pem.Block{Bytes: stub.ServerTLSCert}))\n\t\t\tc.Logger.Errorf(\"Invalid DER for channel %s, endpoint %s, ID %d: %v\", channel, stub.Endpoint, stub.ID, pemString)\n\t\t\treturn nil, errors.Wrap(err, \"invalid certificate DER\")\n\t\t}\n\n\t\tc.Logger.Debug(\"Connecting to\", stub.RemoteNode, \"for channel\", channel)\n\n\t\tconn, err := c.Connections.Connection(stub.Endpoint, stub.ServerTLSCert)\n\t\tif err != nil {\n\t\t\tc.Logger.Warningf(\"Unable to obtain connection to %d(%s) (channel %s): %v\", stub.ID, stub.Endpoint, channel, err)\n\t\t\treturn nil, err\n\t\t}\n\n\t\tprobeConnection := func(conn *grpc.ClientConn) error {\n\t\t\tconnState := conn.GetState()\n\t\t\tif connState == connectivity.Connecting {\n\t\t\t\treturn errors.Errorf(\"connection to %d(%s) is in state %s\", stub.ID, stub.Endpoint, connState)\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\n\t\tclusterClient := orderer.NewClusterClient(conn)\n\t\tgetStream := func(ctx context.Context) (StepClientStream, error) {\n\t\t\tstream, err := clusterClient.Step(ctx)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tstepClientStream := &CommClientStream{\n\t\t\t\tStepClient: stream,\n\t\t\t}\n\t\t\treturn stepClientStream, nil\n\t\t}\n\n\t\tworkerCountReporter := workerCountReporter{\n\t\t\tchannel: channel,","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/orderer/common/cluster/comm.go#L274-L310","documentation":"In createRemoteContext, the probeConnection helper checks the gRPC ClientConn state right after dialing; if the connection is still in connectivity.Connecting, it refuses to hand back a RemoteContext. This is a transient condition: the TCP/TLS handshake to the remote orderer has not completed yet, so the stream factory would be backed by a not-ready connection.","triggerScenarios":"Dialing a remote cluster node whose gRPC channel is still in the Connecting state - typically slow network, TLS handshake in progress, or the remote endpoint not yet listening when the first request arrives.","commonSituations":"Cold start of the ordering service where nodes dial peers before all nodes are up; slow or lossy network between datacenters; DNS resolution delays; remote orderer still booting or restarting under load.","solutions":["Retry the request after a short delay - the connection state usually transitions to Ready on its own.","Verify the remote orderer endpoint (host:port) is correct and the process is running and listening.","Check network latency/firewall rules between orderers that may slow or block the TLS handshake.","Increase gRPC dial/connect timeouts in the cluster configuration if handshakes are consistently slow."],"exampleFix":"// before\nremoteCtx, err := comm.Remote(channel, id) // may hit Connecting state\n// after\nremoteCtx, err := comm.Remote(channel, id)\nif err != nil && strings.Contains(err.Error(), \"is in state Connecting\") {\n    time.Sleep(500 * time.Millisecond)\n    remoteCtx, err = comm.Remote(channel, id)\n}","handlingStrategy":"retry","validationCode":"// Go: probe the conn state yourself before using the remote context\nstate := conn.GetState()\nif state == connectivity.Connecting {\n    // wait for readiness instead of failing\n    conn.WaitForStateChange(context.Background(), state)\n}","typeGuard":"func connReady(conn *grpc.ClientConn) bool {\n    return conn.GetState() == connectivity.Ready\n}","tryCatchPattern":"var remoteCtx *cluster.RemoteContext\nerr := backoff.Retry(func() error {\n    var err error\n    remoteCtx, err = comm.Remote(channel, id)\n    if err != nil && strings.Contains(err.Error(), \"is in state Connecting\") {\n        return err // transient - retry\n    }\n    return backoff.Permanent(err) // other errors are fatal\n}, backoff.WithMaxRetries(backoff.NewExponentialBackOff(), 5))","preventionTips":["Treat Connecting-state errors as transient and wrap Remote calls in bounded exponential-backoff retries.","Ensure all orderers are up before starting dependent workloads (readiness probes).","Check DNS and firewall rules so TLS handshakes complete promptly.","Tune cluster dial timeout settings for high-latency links."],"tags":["fabric","orderer","grpc","connection","timeout"],"backgroundTag":"connection-connecting","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}