diff --git a/docs/core-fabric.md b/docs/core-fabric.md index c3390d2b6..83f74b2fc 100644 --- a/docs/core-fabric.md +++ b/docs/core-fabric.md @@ -297,10 +297,10 @@ fabric: ordering: # number of retries to attempt to send a transaction to an orderer - # If not specified or set to 0, it will default to 3 retries + # If not specified or set to 0, it will default to 3 retries. The orderer is picked randomly for every attempt. numRetries: 3 - # retryInternal specifies the amount of time to wait before retrying a connection to the ordering service, it has no default and must be specified - retryInterval: 3s + # retryInternal specifies the amount of time to wait before retrying a connection to the ordering service, it defaults to 500ms + retryInterval: 500ms # here is possible to disable tls just for the ordering service. # if this key is not specified, then the `tls` section is used. tlsEnabled: true diff --git a/platform/fabric/core/generic/committer/committer.go b/platform/fabric/core/generic/committer/committer.go index dd8d24dec..4f46a24d2 100644 --- a/platform/fabric/core/generic/committer/committer.go +++ b/platform/fabric/core/generic/committer/committer.go @@ -867,6 +867,10 @@ func (c *Committer) applyBundle(bundle *channelconfig.Bundle) error { tlsRootCerts = append(tlsRootCerts, msp.GetTLSRootCerts()...) tlsRootCerts = append(tlsRootCerts, msp.GetTLSIntermediateCerts()...) for _, endpoint := range org.Endpoints() { + if len(endpoint) == 0 { + c.logger.Debugf("[Channel: %s] empty endpoint for %s, skipping", c.ChannelConfig.ID(), org.MSPID()) + continue + } c.logger.Debugf("[Channel: %s] Adding orderer endpoint: [%s:%s:%s]", c.ChannelConfig.ID(), org.Name(), org.MSPID(), endpoint) newOrderers = append(newOrderers, &grpc.ConnectionConfig{ Address: endpoint, @@ -877,8 +881,16 @@ func (c *Committer) applyBundle(bundle *channelconfig.Bundle) error { }) } // If the Orderer MSP config omits the Endpoints and there is only one orderer org, we try to get the addresses from another key in the channel config. - if len(newOrderers) == 0 && len(orgs) == 1 { - for _, endpoint := range bundle.ChannelConfig().OrdererAddresses() { + // This is only here for backwards compatibility and is deprecated in Fabric 3. + // https://hyperledger-fabric.readthedocs.io/en/latest/upgrade_to_newest_version.html#define-ordering-node-endpoint-per-org + addr := bundle.ChannelConfig().OrdererAddresses() + if len(newOrderers) == 0 && len(orgs) == 1 && len(addr) > 0 { + c.logger.Infof("falling back to OrdererAddresses field in channel config (deprecated, please refer to Fabric docs)") + for _, endpoint := range addr { + if len(endpoint) == 0 { + c.logger.Debugf("[Channel: %s] empty orderer address, skipping", c.ChannelConfig.ID()) + continue + } c.logger.Debugf("[Channel: %s] Adding orderer address [%s:%s:%s]", c.ChannelConfig.ID(), org.Name(), org.MSPID(), endpoint) newOrderers = append(newOrderers, &grpc.ConnectionConfig{ Address: endpoint, diff --git a/platform/fabric/core/generic/config/service.go b/platform/fabric/core/generic/config/service.go index 2adad3505..ce1055a58 100644 --- a/platform/fabric/core/generic/config/service.go +++ b/platform/fabric/core/generic/config/service.go @@ -23,6 +23,7 @@ import ( const ( defaultMSPCacheSize = 3 defaultBroadcastNumRetries = 3 + defaultBroadcastRetryInterval = 500 * time.Millisecond vaultPersistenceOptsKey = "vault.persistence.opts" defaultOrderingConnectionPoolSize = 10 defaultNumRetries = 3 @@ -313,7 +314,10 @@ func (s *Service) BroadcastNumRetries() int { } func (s *Service) BroadcastRetryInterval() time.Duration { - return s.GetDuration("ordering.retryInterval") + if s.IsSet("ordering.retryInterval") { + return s.GetDuration("ordering.retryInterval") + } + return defaultBroadcastRetryInterval } func (s *Service) OrdererConnectionPoolSize() int { diff --git a/platform/fabric/core/generic/delivery/delivery.go b/platform/fabric/core/generic/delivery/delivery.go index a0e4f08b5..3d90c34b3 100644 --- a/platform/fabric/core/generic/delivery/delivery.go +++ b/platform/fabric/core/generic/delivery/delivery.go @@ -148,7 +148,7 @@ func (d *Delivery) Run(ctx context.Context) error { span.AddEvent("connect") df, err = d.connect(ctx) if err != nil { - logger.Errorf("failed connecting to delivery service [%s:%s] [%s]. Wait 10 sec before reconnecting", d.NetworkName, d.channel, err) + logger.Errorf("failed connecting to delivery service [%s:%s] [%s]. Wait %.1fs before reconnecting", d.NetworkName, d.channel, err, waitTime.Seconds()) time.Sleep(waitTime) if logger.IsEnabledFor(zapcore.DebugLevel) { logger.Debugf("reconnecting to delivery service [%s:%s]", d.NetworkName, d.channel) diff --git a/platform/fabric/core/generic/ordering/cft.go b/platform/fabric/core/generic/ordering/cft.go index 672798333..b6ac42856 100644 --- a/platform/fabric/core/generic/ordering/cft.go +++ b/platform/fabric/core/generic/ordering/cft.go @@ -123,7 +123,7 @@ func (o *CFTBroadcaster) getConnection(ctx context.Context) (*Connection, error) oClient, err := client.OrdererClient() if err != nil { rpcStatus, _ := status.FromError(err) - return nil, errors.Wrapf(err, "failed to new a broadcast, rpcStatus=%+v", rpcStatus) + return nil, errors.Wrapf(err, "failed to new a broadcast for %s, rpcStatus=%+v", to.Address, rpcStatus) } stream, err := oClient.Broadcast(ctx) diff --git a/platform/view/services/grpc/client.go b/platform/view/services/grpc/client.go index 1974af896..bb20d8717 100644 --- a/platform/view/services/grpc/client.go +++ b/platform/view/services/grpc/client.go @@ -297,6 +297,9 @@ func (client *Client) SetServerRootCAs(serverRoots [][]byte) error { // overrides the server name used to verify the hostname on the // certificate returned by a server when using TLS func (client *Client) NewConnection(address string, tlsOptions ...TLSOption) (*grpc.ClientConn, error) { + if len(address) == 0 { + return nil, errors.New("address is empty") + } var dialOpts []grpc.DialOption dialOpts = append(dialOpts, client.dialOpts...)