sdk实例化客户端时遇到报错
来源:7-12 案例实战外部服务B
酒醉一斤半
2020-06-18
sdk相关代码如下:
package main
import (
"fmt"
"github.com/hyperledger/fabric-sdk-go/pkg/client/channel"
"github.com/hyperledger/fabric-sdk-go/pkg/core/config"
"github.com/hyperledger/fabric-sdk-go/pkg/fabsdk"
)
func main(){}
//封装全局变量
var (
sdk *fabsdk.FabricSDK
configFile = "./config.yaml"
channelID = "testchannel"
org = "Org1"
user = "Admin"
chaincodeID = "test"
cli *channel.Client
)
func init(){
//实例化sdk
var sdkErr error
sdk,sdkErr=fabsdk.New(config.FromFile(configFile))
if sdkErr!=nil{
panic(sdkErr)
}
//生成通道上下文环境
ctx := sdk.ChannelContext(channelID,fabsdk.WithOrg(org),fabsdk.WithUser(user))
//实例化客户端
var cliErr error
cli,cliErr=channel.New(ctx)
if cliErr!=nil{
panic(cliErr)
}
fmt.Println(cli)
}
sdk配置如下:
#
# Copyright SecureKey Technologies Inc. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# The network connection profile provides client applications the information about the target
# blockchain network that are necessary for the applications to interact with it. These are all
# knowledge that must be acquired from out-of-band sources. This file provides such a source.
#
#
# Schema version of the content. Used by the SDK to apply the corresponding parsing rules.
#
version: 1.0.0
#
# The client section used by GO SDK.
#
client:
# Which organization does this application instance belong to? The value must be the name of an org
# defined under "organizations"
organization: org1
logging:
level: debug
# Global configuration for peer, event service and orderer timeouts
# if this this section is omitted, then default values will be used (same values as below)
# peer:
# timeout:
# connection: 10s
# response: 180s
# discovery:
# # Expiry period for discovery service greylist filter
# # The channel client will greylist peers that are found to be offline
# # to prevent re-selecting them in subsequent retries.
# # This interval will define how long a peer is greylisted
# greylistExpiry: 10s
# the below timeouts are commented out to use the default values that are found in
# "pkg/fab/endpointconfig.go"
# the client is free to override the default values by uncommenting and resetting
# the values as they see fit in their config file
# timeout:
# connection: 15s
# registrationResponse: 15s
# orderer:
# timeout:
# connection: 15s
# response: 15s
# global:
# timeout:
# query: 180s
# execute: 180s
# resmgmt: 180s
# cache:
# connectionIdle: 30s
# eventServiceIdle: 2m
# channelConfig: 30m
# channelMembership: 30s
# discovery: 10s
# selection: 10m
# Root of the MSP directories with keys and certs.
cryptoconfig:
path: ${GOPATH}/src/github.com/hyperledger/fabric/firelinks/deploy/crypto-config
# Some SDKs support pluggable KV stores, the properties under "credentialStore"
# are implementation specific
credentialStore:
# [Optional]. Used by user store. Not needed if all credentials are embedded in configuration
# and enrollments are performed elswhere.
path: "/tmp/state-store"
# [Optional]. Specific to the CryptoSuite implementation used by GO SDK. Software-based implementations
# requiring a key store. PKCS#11 based implementations does not.
cryptoStore:
# Specific to the underlying KeyValueStore that backs the crypto key store.
path: /tmp/msp
# [Optional] BCCSP config for the client. Used by GO SDK.
BCCSP:
security:
enabled: true
default:
provider: "SW"
hashAlgorithm: "SHA2"
softVerify: true
level: 256
#
# [Optional]. But most apps would have this section so that channel objects can be constructed
# based on the content below. If an app is creating channels, then it likely will not need this
# section.
#
channels:
# Default channel is used if channel configuration is missing or if defined channel configuration is missing info
# If channel doesn't define peers then peers from default channel will be used
# If channel doesn't define orderes then orderes from default channel will be used
# If channel doesn't define policies then policies from default channel will be used.
# Also, if channel defines policies and some policy info is missing than that missing info will be filled from default channel.
_default:
# [Optional]. list of peers from participating orgs
peers:
peer0.org1.example.com:
# [Optional]. will this peer be sent transaction proposals for endorsement? The peer must
# have the chaincode installed. The app can also use this property to decide which peers
# to send the chaincode install request. Default: true
endorsingPeer: true
# [Optional]. will this peer be sent query proposals? The peer must have the chaincode
# installed. The app can also use this property to decide which peers to send the
# chaincode install request. Default: true
chaincodeQuery: true
# [Optional]. will this peer be sent query proposals that do not require chaincodes, like
# queryBlock(), queryTransaction(), etc. Default: true
ledgerQuery: true
# [Optional]. will this peer be the target of the SDK's listener registration? All peers can
# produce events but the app typically only needs to connect to one to listen to events.
# Default: true
eventSource: true
# [Optional]. The application can use these options to perform channel operations like retrieving channel
# config etc.
policies:
#[Optional] options for retrieving discovery info
discovery:
#[Optional] discovery info will be retrieved for these number of random targets
maxTargets: 2
#[Optional] retry options for retriving discovery info
retryOpts:
#[Optional] number of retry attempts
attempts: 4
#[Optional] the back off interval for the first retry attempt
initialBackoff: 500ms
#[Optional] the maximum back off interval for any retry attempt
maxBackoff: 5s
#[Optional] he factor by which the initial back off period is exponentially incremented
backoffFactor: 2.0
#[Optional] options for selection service
selection:
#[Optional] endorser selection sorting strategy. Possible values: [BlockHeightPriority,Balanced]
SortingStrategy: BlockHeightPriority
#[Optional] load-balancer type. Possible values: [RoundRobin,Random]
Balancer: RoundRobin
#[Optional] the number of blocks from the highest block number of a group of peers that a peer
#can lag behind and still be considered to be up-to-date. These peers will be sorted using the
#given Balancer. If a peer's block height falls behind this threshold then it will be demoted
#to a lower priority list of peers which will be sorted according to block height.
#Note: This property only applies to BlockHeightPriority sorter.
BlockHeightLagThreshold: 5
#[Optional] options for retrieving channel configuration blocks
queryChannelConfig:
#[Optional] min number of success responses (from targets/peers)
minResponses: 1
#[Optional] channel config will be retrieved for these number of random targets
maxTargets: 1
#[Optional] retry options for query config block
retryOpts:
#[Optional] number of retry attempts
attempts: 5
#[Optional] the back off interval for the first retry attempt
initialBackoff: 500ms
#[Optional] the maximum back off interval for any retry attempt
maxBackoff: 5s
#[Optional] he factor by which the initial back off period is exponentially incremented
backoffFactor: 2.0
#[Optional] options for the event service
eventService:
# [Optional] resolverStrategy specifies the peer resolver strategy to use when connecting to a peer
# Possible values: [PreferOrg (default), MinBlockHeight, Balanced]
#
# PreferOrg:
# Determines which peers are suitable based on block height lag threshold, although will prefer the peers in the
# current org (as long as their block height is above a configured threshold). If none of the peers from the current org
# are suitable then a peer from another org is chosen.
# MinBlockHeight:
# Chooses the best peer according to a block height lag threshold. The maximum block height of all peers is
# determined and the peers whose block heights are under the maximum height but above a provided "lag" threshold are load
# balanced. The other peers are not considered.
# Balanced:
# Chooses peers using the configured balancer.
resolverStrategy: PreferOrg
# [Optional] balancer is the balancer to use when choosing a peer to connect to
# Possible values: [Random (default), RoundRobin]
balancer: RoundRobin
# [Optional] blockHeightLagThreshold sets the block height lag threshold. This value is used for choosing a peer
# to connect to. If a peer is lagging behind the most up-to-date peer by more than the given number of
# blocks then it will be excluded from selection.
# Note that this parameter is applicable only when minBlockHeightResolverMode is set to ResolveByThreshold.
# Default: 5
blockHeightLagThreshold: 2
# [Optional] reconnectBlockHeightLagThreshold - the event client will disconnect from the peer if the peer's
# block height falls behind the specified number of blocks and will reconnect to a better performing peer.
# Note that this parameter is only applicable if peerMonitor is set to Enabled (default).
# Default: 10
# NOTES:
# - Setting this value too low may cause the event client to disconnect/reconnect too frequently, thereby
# affecting performance.
reconnectBlockHeightLagThreshold: 5
# [Optional] peerMonitorPeriod is the period in which the connected peer is monitored to see if
# the event client should disconnect from it and reconnect to another peer.
# Default: 0 (disabled) for Balanced resolverStrategy; 5s for PreferOrg and MinBlockHeight strategy
peerMonitorPeriod: 3s
# Mychannel overrides initialBackoff for discovery
testchannel:
# [Optional]. list of peers from participating orgs
peers:
peer0.org1.example.com:
endorsingPeer: true
chaincodeQuery: true
ledgerQuery: true
eventSource: true
peer1.org1.example.com:
endorsingPeer: false
chaincodeQuery: false
ledgerQuery: true
eventSource: true
peer2.org1.example.com:
endorsingPeer: false
chaincodeQuery: false
ledgerQuery: true
eventSource: true
policies:
discovery:
retryOpts:
#[Required for override] number of retry attempts
attempts: 4
initialBackoff: 1s
#
# list of participating organizations in this network
#
organizations:
org1:
mspid: Org1MSP
# This org's MSP store (absolute path or relative to client.cryptoconfig)
cryptoPath: peerOrganizations/org1.example.com/users/{username}@org1.example.com/msp
peers:
- peer0.org1.example.com
- peer1.org1.example.com
- peer2.org1.example.com
# Orderer Org name
ordererorg:
# Membership Service Provider ID for this organization
mspID: OrdererMSP
# Needed to load users crypto keys and certs for this org (absolute path or relative to global crypto path, DEV mode)
cryptoPath: ordererOrganizations/example.com/users/{username}@example.com/msp
#
# List of orderers to send transaction and channel create/update requests to. For the time
# being only one orderer is needed. If more than one is defined, which one get used by the
# SDK is implementation specific. Consult each SDK's documentation for its handling of orderers.
#
orderers:
_default:
# common orderer config items between all the orderers in config
# these are standard properties defined by the gRPC library
# they will be passed in as-is to gRPC client constructor
grpcOptions:
# These parameters should be set in coordination with the keepalive policy on the server,
# as incompatible settings can result in closing of connection.
# When duration of the 'keep-alive-time' is set to 0 or less the keep alive client parameters are disabled
keep-alive-time: 0s
keep-alive-timeout: 20s
keep-alive-permit: false
fail-fast: false
# allow-insecure will be taken into consideration if address has no protocol defined, if true then grpc or else grpcs
allow-insecure: true
orderer.example.com:
# [Optional] Default: Infer from hostname
url: orderer.example.com:7050
# these are standard properties defined by the gRPC library
# they will be passed in as-is to gRPC client constructor
grpcOptions:
#ssl-target-name-override: orderer.example.com
# These parameters should be set in coordination with the keepalive policy on the server,
# as incompatible settings can result in closing of connection.
# When duration of the 'keep-alive-time' is set to 0 or less the keep alive client parameters are disabled
#keep-alive-time: 0s
#keep-alive-timeout: 20s
#keep-alive-permit: false
#fail-fast: false
# allow-insecure will be taken into consideration if address has no protocol defined, if true then grpc or else grpcs
#allow-insecure: false
#
# List of peers to send various requests to, including endorsement, query
# and event listener registration.
#
peers:
_default:
#common grpc options between all the peers
grpcOptions:
# These parameters should be set in coordination with the keepalive policy on the server,
# as incompatible settings can result in closing of connection.
# When duration of the 'keep-alive-time' is set to 0 or less the keep alive client parameters are disabled
keep-alive-time: 0s
keep-alive-timeout: 20s
keep-alive-permit: false
fail-fast: false
# allow-insecure will be taken into consideration if address has no protocol defined, if true then grpc or else grpcs
allow-insecure: true
peer0.org1.example.com:
# this URL is used to send endorsement and query requests
# [Optional] Default: Infer from hostname
url: peer0.org1.example.com:7051
#grpcOptions:
# ssl-target-name-override: peer0.org1.example.com
peer1.org1.example.com:
# this URL is used to send endorsement and query requests
url: peer1.org1.example.com:8051
#grpcOptions:
# ssl-target-name-override: peer1.org1.example.com
peer2.org1.example.com:
url: peer2.org1.example.com:9051
#grpcOptions:
# ssl-target-name-override: peer2.org1.example.com
#
# Fabric-CA is a special kind of Certificate Authority provided by Hyperledger Fabric which allows
# certificate management to be done via REST APIs. Application may choose to use a standard
# Certificate Authority instead of Fabric-CA, in which case this section would not be specified.
#
#certificateAuthorities:
# ca.org1.example.com:
# # [Optional] Default: Infer from hostname
# url: https://ca.org1.example.com:7054
# # [Optional] The optional server name for target override
# #grpcOptions:
# # ssl-target-name-override: ca.org1.example.com
# tlsCACerts:
# # Comma-Separated list of paths
# path: ${FABRIC_SDK_GO_PROJECT_PATH}/${CRYPTOCONFIG_FIXTURES_PATH}/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem
# # Client key and cert for SSL handshake with Fabric CA
# client:
# key:
# path: ${FABRIC_SDK_GO_PROJECT_PATH}/${CRYPTOCONFIG_FIXTURES_PATH}/peerOrganizations/tls.example.com/users/User1@tls.example.com/tls/client.key
# cert:
# path: ${FABRIC_SDK_GO_PROJECT_PATH}/${CRYPTOCONFIG_FIXTURES_PATH}/peerOrganizations/tls.example.com/users/User1@tls.example.com/tls/client.crt
#
# # Fabric-CA supports dynamic user enrollment via REST APIs. A "root" user, a.k.a registrar, is
# # needed to enroll and invoke new users.
# registrar:
# enrollId: admin
# enrollSecret: adminpw
# # [Optional] The optional name of the CA.
# caName: ca.org1.example.com
# tlsca.org1.example.com:
# # [Optional] Default: Infer from hostname
# url: https://ca.org1.example.com:7154
# tlsCACerts:
# # Comma-Separated list of paths
# path: ${FABRIC_SDK_GO_PROJECT_PATH}/${CRYPTOCONFIG_FIXTURES_PATH}/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem
# # Client key and cert for SSL handshake with Fabric CA
# client:
# key:
# path: ${FABRIC_SDK_GO_PROJECT_PATH}/${CRYPTOCONFIG_FIXTURES_PATH}/peerOrganizations/tls.example.com/users/User1@tls.example.com/tls/client.key
# cert:
# path: ${FABRIC_SDK_GO_PROJECT_PATH}/${CRYPTOCONFIG_FIXTURES_PATH}/peerOrganizations/tls.example.com/users/User1@tls.example.com/tls/client.crt
#
# # Fabric-CA supports dynamic user enrollment via REST APIs. A "root" user, a.k.a registrar, is
# # needed to enroll and invoke new users.
# registrar:
# enrollId: admin2
# enrollSecret: adminpw2
# # [Optional] The optional name of the CA.
# caName: tlsca.org1.example.com
# ca.org2.example.com:
# url: https://ca.org2.example.com:8054
# # [Optional] The optional server name for target override
# #grpcOptions:
# # ssl-target-name-override: ca.org2.example.com
# tlsCACerts:
# # Comma-Separated list of paths
# path: ${FABRIC_SDK_GO_PROJECT_PATH}/${CRYPTOCONFIG_FIXTURES_PATH}/peerOrganizations/org2.example.com/tlsca/tlsca.org2.example.com-cert.pem
# # Client key and cert for SSL handshake with Fabric CA
# client:
# key:
# path: ${FABRIC_SDK_GO_PROJECT_PATH}/${CRYPTOCONFIG_FIXTURES_PATH}/peerOrganizations/tls.example.com/users/User1@tls.example.com/tls/client.key
# cert:
# path: ${FABRIC_SDK_GO_PROJECT_PATH}/${CRYPTOCONFIG_FIXTURES_PATH}/peerOrganizations/tls.example.com/users/User1@tls.example.com/tls/client.crt
#
# # Fabric-CA supports dynamic user enrollment via REST APIs. A "root" user, a.k.a registrar, is
# # needed to enroll and invoke new users.
# registrar:
# enrollId: admin
# enrollSecret: adminpw
# # [Optional] The optional name of the CA.
# caName: ca.org2.example.com
# EntityMatchers enable substitution of network hostnames with static configurations
# so that properties can be mapped. Regex can be used for this purpose
# UrlSubstitutionExp can be empty which means the same network hostname will be used
# UrlSubstitutionExp can be given same as mapped peer url, so that mapped peer url can be used
# UrlSubstitutionExp can have golang regex matchers like ${1}.local.example.${2}:${3} for pattern
# like peer0.org1.example.com:1234 which converts peer0.org1.example.com to peer0.org1.local.example.com:1234
# sslTargetOverrideUrlSubstitutionExp follow in the same lines as
# SubstitutionExp for the fields gprcOptions.ssl-target-name-override respectively
# In any case mappedHost's config will be used, so mapped host cannot be empty, if entityMatchers are used
entityMatchers:
peer:
- pattern: (\w+).org1.example.com
urlSubstitutionExp: ${1}.org1.example.com:7051
sslTargetOverrideUrlSubstitutionExp: ${1}.org1.example.com
mappedHost: peer0.org1.example.com
- pattern: (\w+).org1.example.com
urlSubstitutionExp: ${1}.org1.example.com:8051
sslTargetOverrideUrlSubstitutionExp: ${1}.org1.example.com
mappedHost: peer1.org1.example.com
- pattern: (\w+).org1.example.com
urlSubstitutionExp: ${1}.org1.example.com:9051
sslTargetOverrideUrlSubstitutionExp: ${1}.org1.example.com
mappedHost: peer2.org1.example.com
orderer:
- pattern: (\w+).example.(\w+)
urlSubstitutionExp: orderer.example.com:7050
sslTargetOverrideUrlSubstitutionExp: orderer.example.com
mappedHost: orderer.example.com
#entityMatchers:
# peer:
# - pattern: (\w+).org1.example.com:(\d+)
# urlSubstitutionExp: ${1}.org1.example.com:${2}
# sslTargetOverrideUrlSubstitutionExp: ${1}.org1.example.com
# mappedHost: peer0.org1.example.com
#
# - pattern: (\w+).org2.example.com:(\d+)
# urlSubstitutionExp: ${1}.org2.example.com:${2}
# sslTargetOverrideUrlSubstitutionExp: ${1}.org2.example.com
# mappedHost: peer0.org2.example.com
#
# - pattern: (\w+).org1.example.(\w+)
# urlSubstitutionExp: peer0.org1.example.com:7051
# sslTargetOverrideUrlSubstitutionExp: peer0.org1.example.com
# mappedHost: peer0.org1.example.com
#
# - pattern: (\w+).org2.example.(\w+)
# urlSubstitutionExp: peer0.org2.example.com:8051
# sslTargetOverrideUrlSubstitutionExp: peer0.org2.example.com
# mappedHost: peer0.org2.example.com
#
# - pattern: (\w+).example1.(\w+):(\d+)
# urlSubstitutionExp: ${1}.org1.example.${2}:${3}
# sslTargetOverrideUrlSubstitutionExp: ${1}.org1.example.${2}
# mappedHost: peer0.org1.example.com
#
# - pattern: (\w+).org1.example.(\w+):(\d+)
# urlSubstitutionExp: peer0.org1.example.com:7051
# sslTargetOverrideUrlSubstitutionExp: peer0.org1.example.com
# mappedHost: peer0.org1.example.com
#
# orderer:
# - pattern: (\w+).example.(\w+)
# urlSubstitutionExp: orderer.example.com:7050
# sslTargetOverrideUrlSubstitutionExp: orderer.example.com
# mappedHost: orderer.example.com
#
# - pattern: (\w+).example2.(\w+)
# urlSubstitutionExp: localhost:7050
# sslTargetOverrideUrlSubstitutionExp: localhost
# mappedHost: orderer.example.com
#
# - pattern: (\w+).example3.(\w+)
# urlSubstitutionExp:
# sslTargetOverrideUrlSubstitutionExp:
# mappedHost: orderer.example.com
#
# - pattern: (\w+).example4.(\w+):(\d+)
# urlSubstitutionExp: ${1}.example.${2}:${3}
# sslTargetOverrideUrlSubstitutionExp: ${1}.example.${2}
# mappedHost: orderer.example.com
#
# certificateAuthority:
# - pattern: (\w+).org1.example.(\w+)
# urlSubstitutionExp:
# sslTargetOverrideUrlSubstitutionExp: ca.example.com
# mappedHost: ca.org1.example.com
#
# - pattern: (\w+).org2.example.(\w+)
# urlSubstitutionExp:
# sslTargetOverrideUrlSubstitutionExp: ca.example.com
# mappedHost: ca.org2.example.com
###############################################################################
#
# Operations section
# copied from Fabric's core.yaml
###############################################################################
operations:
# host and port for the operations server
listenAddress: 127.0.0.1:8080
# TLS configuration for the operations endpoint
tls:
# TLS enabled
enabled: false
# TODO replace cert.file, key.file and clientRootCAs.files to tlsCACerts as used elsewhere in this config file
# path to PEM encoded server certificate for the operations server
cert:
file:
# path to PEM encoded server key for the operations server
key:
file:
# require client certificate authentication to access all resources
clientAuthRequired: false
# paths to PEM encoded ca certificates to trust for client authentication
clientRootCAs:
files: []
###############################################################################
#
# Metrics section
# copied from Fabric's core.yaml
###############################################################################
metrics:
# metrics provider is one of statsd, prometheus, or disabled
provider: prometheus
# statsd configuration
statsd:
# network type: tcp or udp
network: udp
# statsd server address
address: 127.0.0.1:8125
# the interval at which locally cached counters and gauges are pushed
# to statsd; timings are pushed immediately
writeInterval: 10s
# prefix is prepended to all emitted statsd metrics
prefix:
日志如下:
[root@localhost application]# go run main.go
[fabsdk/core] 2020/06/18 09:25:25 UTC - sw.getOptsByConfig -> DEBU Initialized SW cryptosuite
[fabsdk/fab] 2020/06/18 09:25:25 UTC - sw.(*fileBasedKeyStore).createKeyStoreIfNotExists -> DEBU KeyStore path [/tmp/msp/keystore] missing [true]: [<clean>]
[fabsdk/fab] 2020/06/18 09:25:25 UTC - sw.(*fileBasedKeyStore).createKeyStore -> DEBU Creating KeyStore at [/tmp/msp/keystore]...
[fabsdk/fab] 2020/06/18 09:25:25 UTC - sw.(*fileBasedKeyStore).createKeyStore -> DEBU KeyStore created at [/tmp/msp/keystore].
[fabsdk/fab] 2020/06/18 09:25:25 UTC - n/a -> DEBU KeyStore opened at [/tmp/msp/keystore]...done
[fabsdk/fab] 2020/06/18 09:25:25 UTC - fab.(*EndpointConfig).loadEndpointConfiguration -> DEBU Client is: {Organization:org1 TLSCerts:{Client:{Key:{Path: Pem: bytes:[]} Cert:{Path: Pem: bytes:[]}}}}
[fabsdk/fab] 2020/06/18 09:25:25 UTC - fab.(*EndpointConfig).loadEndpointConfiguration -> DEBU channels are: map[_default:{Orderers:[] Peers:map[peer0.org1.example.com:{EndorsingPeer:true ChaincodeQuery:true LedgerQuery:true EventSource:true}] Policies:{QueryChannelConfig:{MinResponses:1 MaxTargets:1 RetryOpts:{Attempts:5 InitialBackoff:500ms MaxBackoff:5s BackoffFactor:2 RetryableCodes:map[]}} Discovery:{MinResponses:0 MaxTargets:2 RetryOpts:{Attempts:4 InitialBackoff:500ms MaxBackoff:5s BackoffFactor:2 RetryableCodes:map[]}} Selection:{SortingStrategy:BlockHeightPriority Balancer:RoundRobin BlockHeightLagThreshold:5} EventService:{ResolverStrategy:PreferOrg MinBlockHeightResolverMode: Balancer:RoundRobin BlockHeightLagThreshold:2 PeerMonitor: ReconnectBlockHeightLagThreshold:5 PeerMonitorPeriod:3s}}} testchannel:{Orderers:[] Peers:map[peer0.org1.example.com:{EndorsingPeer:true ChaincodeQuery:true LedgerQuery:true EventSource:true} peer1.org1.example.com:{EndorsingPeer:false ChaincodeQuery:false LedgerQuery:true EventSource:true} peer2.org1.example.com:{EndorsingPeer:false ChaincodeQuery:false LedgerQuery:true EventSource:true}] Policies:{QueryChannelConfig:{MinResponses:0 MaxTargets:0 RetryOpts:{Attempts:0 InitialBackoff:0s MaxBackoff:0s BackoffFactor:0 RetryableCodes:map[]}} Discovery:{MinResponses:0 MaxTargets:0 RetryOpts:{Attempts:4 InitialBackoff:1s MaxBackoff:0s BackoffFactor:0 RetryableCodes:map[]}} Selection:{SortingStrategy: Balancer: BlockHeightLagThreshold:0} EventService:{ResolverStrategy: MinBlockHeightResolverMode: Balancer: BlockHeightLagThreshold:0 PeerMonitor: ReconnectBlockHeightLagThreshold:0 PeerMonitorPeriod:0s}}}]
[fabsdk/fab] 2020/06/18 09:25:25 UTC - fab.(*EndpointConfig).loadEndpointConfiguration -> DEBU organizations are: map[ordererorg:{MSPID:OrdererMSP CryptoPath:ordererOrganizations/example.com/users/{username}@example.com/msp Users:map[] Peers:[] CertificateAuthorities:[]} org1:{MSPID:Org1MSP CryptoPath:peerOrganizations/org1.example.com/users/{username}@org1.example.com/msp Users:map[] Peers:[peer0.org1.example.com peer1.org1.example.com peer2.org1.example.com] CertificateAuthorities:[]}]
[fabsdk/fab] 2020/06/18 09:25:25 UTC - fab.(*EndpointConfig).loadEndpointConfiguration -> DEBU orderers are: map[_default:{URL: GRPCOptions:map[allow-insecure:true fail-fast:false keep-alive-permit:false keep-alive-time:0s keep-alive-timeout:20s] TLSCACerts:{Path: Pem: bytes:[]}} orderer.example.com:{URL:orderer.example.com:7050 GRPCOptions:map[] TLSCACerts:{Path: Pem: bytes:[]}}]
[fabsdk/fab] 2020/06/18 09:25:25 UTC - fab.(*EndpointConfig).loadEndpointConfiguration -> DEBU peers are: map[_default:{URL: GRPCOptions:map[allow-insecure:true fail-fast:false keep-alive-permit:false keep-alive-time:0s keep-alive-timeout:20s] TLSCACerts:{Path: Pem: bytes:[]}} peer0.org1.example.com:{URL:peer0.org1.example.com:7051 GRPCOptions:map[] TLSCACerts:{Path: Pem: bytes:[]}} peer1.org1.example.com:{URL:peer1.org1.example.com:8051 GRPCOptions:map[] TLSCACerts:{Path: Pem: bytes:[]}} peer2.org1.example.com:{URL:peer2.org1.example.com:9051 GRPCOptions:map[] TLSCACerts:{Path: Pem: bytes:[]}}]
[fabsdk/fab] 2020/06/18 09:25:25 UTC - fab.(*EndpointConfig).compileMatchers -> DEBU Matchers are: {matchers:map[orderer:[{Pattern:(\w+).example.(\w+) URLSubstitutionExp:orderer.example.com:7050 SSLTargetOverrideURLSubstitutionExp:orderer.example.com MappedHost:orderer.example.com MappedName: IgnoreEndpoint:false}] peer:[{Pattern:(\w+).org1.example.com URLSubstitutionExp:${1}.org1.example.com:7051 SSLTargetOverrideURLSubstitutionExp:${1}.org1.example.com MappedHost:peer0.org1.example.com MappedName: IgnoreEndpoint:false} {Pattern:(\w+).org1.example.com URLSubstitutionExp:${1}.org1.example.com:8051 SSLTargetOverrideURLSubstitutionExp:${1}.org1.example.com MappedHost:peer1.org1.example.com MappedName: IgnoreEndpoint:false} {Pattern:(\w+).org1.example.com URLSubstitutionExp:${1}.org1.example.com:9051 SSLTargetOverrideURLSubstitutionExp:${1}.org1.example.com MappedHost:peer2.org1.example.com MappedName: IgnoreEndpoint:false}]]}
[fabsdk/msp] 2020/06/18 09:25:25 UTC - msp.(*IdentityConfig).loadIdentityConfigEntities -> DEBU Client is: {Organization:org1 Logging:{Level:debug} CryptoConfig:{Path:${GOPATH}/src/github.com/hyperledger/fabric/firelinks/deploy/crypto-config} TLSCerts:{Client:{Key:{Path: Pem: bytes:[]} Cert:{Path: Pem: bytes:[]}} SystemCertPool:false} CredentialStore:{Path:/tmp/state-store CryptoStore:{Path:/tmp/msp}}}
[fabsdk/msp] 2020/06/18 09:25:25 UTC - msp.(*IdentityConfig).loadIdentityConfigEntities -> DEBU organizations are: map[ordererorg:{MSPID:OrdererMSP CryptoPath:ordererOrganizations/example.com/users/{username}@example.com/msp Users:map[] Peers:[] CertificateAuthorities:[]} org1:{MSPID:Org1MSP CryptoPath:peerOrganizations/org1.example.com/users/{username}@org1.example.com/msp Users:map[] Peers:[peer0.org1.example.com peer1.org1.example.com peer2.org1.example.com] CertificateAuthorities:[]}]
[fabsdk/msp] 2020/06/18 09:25:25 UTC - msp.(*IdentityConfig).loadIdentityConfigEntities -> DEBU certificateAuthorities are: map[]
[fabsdk/msp] 2020/06/18 09:25:25 UTC - msp.(*IdentityConfig).compileMatchers -> DEBU Matchers are: {matchers:map[orderer:[{Pattern:(\w+).example.(\w+) URLSubstitutionExp:orderer.example.com:7050 SSLTargetOverrideURLSubstitutionExp:orderer.example.com MappedHost:orderer.example.com MappedName: IgnoreEndpoint:false}] peer:[{Pattern:(\w+).org1.example.com URLSubstitutionExp:${1}.org1.example.com:7051 SSLTargetOverrideURLSubstitutionExp:${1}.org1.example.com MappedHost:peer0.org1.example.com MappedName: IgnoreEndpoint:false} {Pattern:(\w+).org1.example.com URLSubstitutionExp:${1}.org1.example.com:8051 SSLTargetOverrideURLSubstitutionExp:${1}.org1.example.com MappedHost:peer1.org1.example.com MappedName: IgnoreEndpoint:false} {Pattern:(\w+).org1.example.com URLSubstitutionExp:${1}.org1.example.com:9051 SSLTargetOverrideURLSubstitutionExp:${1}.org1.example.com MappedHost:peer2.org1.example.com MappedName: IgnoreEndpoint:false}]]}
[fabsdk] 2020/06/18 09:25:25 UTC - fabsdk.initSDK -> DEBU SDK initialized successfully
[fabsdk/fab] 2020/06/18 09:25:25 UTC - chconfig.(*params).SetChConfigRefreshInterval -> DEBU RefreshInterval: 1m30s
[fabsdk/util] 2020/06/18 09:25:25 UTC - lazyref.WithRefreshInterval.func1 -> DEBU Checking refreshIntervalSetter
[fabsdk/fab] 2020/06/18 09:25:25 UTC - peer.(*peerEndorser).ProcessTransactionProposal -> DEBU Processing proposal using endorser: peer2.org1.example.com:7051
[fabsdk/fab] 2020/06/18 09:25:25 UTC - comm.(*CachingConnector).DialContext -> DEBU DialContext: peer2.org1.example.com:7051
[fabsdk/fab] 2020/06/18 09:25:25 UTC - comm.(*CachingConnector).createConn -> DEBU creating connection [peer2.org1.example.com:7051]
[fabsdk/fab] 2020/06/18 09:25:25 UTC - comm.(*CachingConnector).createConn -> DEBU storing connection [peer2.org1.example.com:7051]
[fabsdk/fab] 2020/06/18 09:25:25 UTC - comm.(*CachingConnector).removeConn -> DEBU removing connection [peer2.org1.example.com:7051]
[fabsdk/fab] 2020/06/18 09:25:25 UTC - txn.SendProposal.func1 -> DEBU Received error response from txn proposal processing: Transaction processing for endorser [peer2.org1.example.com:7051]: Endorser Client Status Code: (2) CONNECTION_FAILED. Description: dialing connection on target [peer2.org1.example.com:7051]: connection is in TRANSIENT_FAILURE
[fabsdk/common] 2020/06/18 09:25:25 UTC - retry.(*RetryableInvoker).Invoke -> DEBU Failed with err [queryChaincode failed: Transaction processing for endorser [peer2.org1.example.com:7051]: Endorser Client Status Code: (2) CONNECTION_FAILED. Description: dialing connection on target [peer2.org1.example.com:7051]: connection is in TRANSIENT_FAILURE] on attempt #1. Checking if retry is warranted...
[fabsdk/common] 2020/06/18 09:25:25 UTC - retry.(*RetryableInvoker).Invoke -> DEBU ... retry for err [queryChaincode failed: Transaction processing for endorser [peer2.org1.example.com:7051]: Endorser Client Status Code: (2) CONNECTION_FAILED. Description: dialing connection on target [peer2.org1.example.com:7051]: connection is in TRANSIENT_FAILURE] is NOT warranted after 1 attempt(s).
[fabsdk/util] 2020/06/18 09:25:25 UTC - lazyref.(*Reference).setTimerRunning -> DEBU Timer started
[fabsdk/util] 2020/06/18 09:25:25 UTC - lazyref.checkTimeStarted -> DEBU Starting timer
panic: event service creation failed: could not get chConfig cache reference: QueryBlockConfig failed: QueryBlockConfig failed: queryChaincode failed: Transaction processing for endorser [peer2.org1.example.com:7051]: Endorser Client Status Code: (2) CONNECTION_FAILED. Description: dialing connection on target [peer2.org1.example.com:7051]: connection is in TRANSIENT_FAILURE
goroutine 1 [running]:
main.init.0()
/root/gocode/src/github.com/hyperledger/fabric/firelinks/application/main.go:40 +0x279
exit status 2
版本信息:
fabric1.4.8 fabric-sdk-go 最新
提问:
1、entityMatchers配置是否正确?
2、为何尝试连接peer2.org1.example.com:7051端口?(配置的是9051)
3、客户端在做什么?应该如何解决这个问题?
写回答
1回答
-
自游蜗牛
2020-06-20
1 不对哈,我们首先看的是partten。你前三个partten都一样呢
2 因为你partten设置的不对,所以匹配了地一个设置,也就是7051
3 没懂什么意思。干什么?不是在初始化channel的cli么?解决什么问题?
00
相似问题