1. 将节点加入通道时,配置环境变量出现错误,如以下代码:
CORE_PEER_ADDRESS=peer0.org2.example.com:7051
可能出现的错误代码
Error: error getting endorser client for channel: endorser client failed to connect to peer0.org2.example.com:7051: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 172.28.0.3:7051: connect: connection refused"
我们在设置peer0.org1.example.com时已经将监听端口设置为了7051,这里出现了重复定义问题,只要配置不同的监听端口,问题就会解决。常见的端口配置如下:
peer0.org2.example.com:9051
peer0.org1.example.com:7051
peer1.org1.example.com:8051
peer1.org2.example.com:1005
2. invoke时,出现endorsement failure during invoke. response: status:500 message错误
具体错误代码如下
Error:endorsement failure during invoke.response:status:500 message:"make sure the chaincode mycc2 has been successfully defined on channel channel2 and try again:chaincode definition for 'mycc2' exists, but chaincode is not installed"
错误原因:在自定义网络部署时也出现过这个错误,经排查,应该是切换环境变量时切换了cli指定的节点环境变量。
解决方法:在手动启动first-network前,先利用byfn脚本将first-network脚本自动执行一遍。
3. 在升级链码,对链码进行重新打包时,出现以下错误
错误原因:推测是vendor这个文件夹出现了问题
错误代码:
error getting chaincode bytes: failed to calculate dependencies: incomplete package: github.com/hyperledger/fabric-chaincode-go/pkg/statebased
解决方法:
cd fabric-samples/chaincode/abstore/go
GO111MODULE=on go mod vendor #执行这一条指令时要科学上网
4. 启动docker-compose.yaml出现COMPOSE_PROJECT_NAME未定义问题
警告信息:
WARNING: The COMPOSE_PROJECT_NAME variable is not set. Defaulting to a blank string.
错误原因:
在于docker-compose.yaml 文件中设置了一些环境变量,但是在启动过程中并没有传递环境变量值,因此就会出现类似这样的告警信息,如果是容器启动时必须的环境变量,则有可能会报异常或者错误信息
解决方法:
在项目根目录下创建 .env 配置文件
sudo vim .env
在.env文件中填写诸如 key=value 这样格式的环境配置信息,如下所示:
COMPOSE_PROJECT_NAME=hu
5. 在启动节点的时候出现一些WARN和ERRO
orderer0.hu.com
的ERRO日志:
2021-07-05 13:09:32.795 UTC [orderer.consensus.etcdraft] logSendFailure -> ERRO 02c Failed to send StepRequest to 4, because: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial tcp 192.168.80.4:7050: connect: connection refused" channel=hu-channel node=1
2021-07-05 13:09:32.961 UTC [orderer.consensus.etcdraft] logSendFailure -> ERRO 02e Failed to send StepRequest to 5, because: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial tcp 192.168.80.8:7050: connect: connection refused" channel=hu-channel node=1
2021-07-05 13:09:34.447 UTC [orderer.consensus.etcdraft] logSendFailure -> ERRO 036 Failed to send StepRequest to 3, because: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial tcp 192.168.80.9:7050: connect: connection refused" channel=hu-channel node=1
2021-07-05 13:09:34.447 UTC [orderer.consensus.etcdraft] logSendFailure -> ERRO 037 Failed to send StepRequest to 2, because: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial tcp 192.168.80.2:7050: connect: connection refused" channel=hu-channel node=1
orderer1.hu.com
的ERRO日志:
2021-07-05 13:09:35.753 UTC [orderer.consensus.etcdraft] logSendFailure -> ERRO 032 Failed to send StepRequest to 3, because: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial tcp 192.168.80.9:7050: connect: connection refused" channel=hu-channel node=2
2021-07-05 13:09:35.754 UTC [orderer.consensus.etcdraft] logSendFailure -> ERRO 033 Failed to send StepRequest to 4, because: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial tcp 192.168.80.4:7050: connect: connection refused" channel=hu-channel node=2
2021-07-05 13:09:35.754 UTC [orderer.consensus.etcdraft] logSendFailure -> ERRO 034 Failed to send StepRequest to 5, because: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial tcp 192.168.80.8:7050: connect: connection refused" channel=hu-channel node=2
orderer0.hu.com
的WARN日志:
2021-07-06 02:02:06.185 UTC [orderer.common.cluster.puller] probeEndpoint -> WARN 357 Failed connecting to {"CAs":[{"Expired":false,"Issuer":"self","Subject":"CN=tlsca.hu.com,O=hu.com,L=San Francisco,ST=California,C=US"}],"Endpoint":"orderer3.hu.com:7050"}: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 192.168.80.4:7050: connect: connection refused" channel=hu-channel
2021-07-06 02:02:06.189 UTC [orderer.common.cluster.puller] probeEndpoint -> WARN 358 Failed connecting to {"CAs":[{"Expired":false,"Issuer":"self","Subject":"CN=tlsca.hu.com,O=hu.com,L=San Francisco,ST=California,C=US"}],"Endpoint":"orderer1.hu.com:7050"}: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 192.168.80.2:7050: connect: connection refused" channel=hu-channel
2021-07-06 02:02:06.189 UTC [orderer.common.cluster.puller] func1 -> WARN 359 Received error of type 'failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 192.168.80.2:7050: connect: connection refused"' from {"CAs":[{"Expired":false,"Issuer":"self","Subject":"CN=tlsca.hu.com,O=hu.com,L=San Francisco,ST=California,C=US"}],"Endpoint":"orderer1.hu.com:7050"} channel=hu-channel
2021-07-06 02:02:06.192 UTC [orderer.common.cluster.puller] probeEndpoint -> WARN 35a Failed connecting to {"CAs":[{"Expired":false,"Issuer":"self","Subject":"CN=tlsca.hu.com,O=hu.com,L=San Francisco,ST=California,C=US"}],"Endpoint":"orderer2.hu.com:7050"}: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 192.168.80.9:7050: connect: connection refused" channel=hu-channel
2021-07-06 02:02:06.192 UTC [orderer.common.cluster.puller] func1 -> WARN 35b Received error of type 'failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 192.168.80.9:7050: connect: connection refused"' from {"CAs":[{"Expired":false,"Issuer":"self","Subject":"CN=tlsca.hu.com,O=hu.com,L=San Francisco,ST=California,C=US"}],"Endpoint":"orderer2.hu.com:7050"} channel=hu-channel
2021-07-06 02:02:06.196 UTC [orderer.common.cluster.puller] probeEndpoint -> WARN 35c Failed connecting to {"CAs":[{"Expired":false,"Issuer":"self","Subject":"CN=tlsca.hu.com,O=hu.com,L=San Francisco,ST=California,C=US"}],"Endpoint":"orderer4.hu.com:7050"}: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 192.168.80.8:7050: connect: connection refused" channel=hu-channel
2021-07-06 02:02:06.198 UTC [orderer.common.cluster.puller] func1 -> WARN 35d Received error of type 'failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 192.168.80.8:7050: connect: connection refused"' from {"CAs":[{"Expired":false,"Issuer":"self","Subject":"CN=tlsca.hu.com,O=hu.com,L=San Francisco,ST=California,C=US"}],"Endpoint":"orderer4.hu.com:7050"} channel=hu-channel
2021-07-06 02:02:06.353 UTC [orderer.common.cluster.puller] func1 -> WARN 35e Received error of type 'failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 192.168.80.4:7050: connect: connection refused"' from {"CAs":[{"Expired":false,"Issuer":"self","Subject":"CN=tlsca.hu.com,O=hu.com,L=San Francisco,ST=California,C=US"}],"Endpoint":"orderer3.hu.com:7050"} channel=hu-channel
orderer1.hu.com
的WARN日志:
2021-07-06 02:02:06.184 UTC [orderer.common.cluster.puller] probeEndpoint -> WARN 2dd Failed connecting to {"CAs":[{"Expired":false,"Issuer":"self","Subject":"CN=tlsca.hu.com,O=hu.com,L=San Francisco,ST=California,C=US"}],"Endpoint":"orderer2.hu.com:7050"}: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 192.168.80.9:7050: connect: connection refused" channel=hu-channel
2021-07-06 02:02:06.186 UTC [orderer.common.cluster.puller] func1 -> WARN 2de Received error of type 'failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 192.168.80.9:7050: connect: connection refused"' from {"CAs":[{"Expired":false,"Issuer":"self","Subject":"CN=tlsca.hu.com,O=hu.com,L=San Francisco,ST=California,C=US"}],"Endpoint":"orderer2.hu.com:7050"} channel=hu-channel
2021-07-06 02:02:06.187 UTC [orderer.common.cluster.puller] probeEndpoint -> WARN 2df Failed connecting to {"CAs":[{"Expired":false,"Issuer":"self","Subject":"CN=tlsca.hu.com,O=hu.com,L=San Francisco,ST=California,C=US"}],"Endpoint":"orderer4.hu.com:7050"}: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 192.168.80.8:7050: connect: connection refused" channel=hu-channel
2021-07-06 02:02:06.187 UTC [orderer.common.cluster.puller] func1 -> WARN 2e0 Received error of type 'failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 192.168.80.8:7050: connect: connection refused"' from {"CAs":[{"Expired":false,"Issuer":"self","Subject":"CN=tlsca.hu.com,O=hu.com,L=San Francisco,ST=California,C=US"}],"Endpoint":"orderer4.hu.com:7050"} channel=hu-channel
2021-07-06 02:02:06.193 UTC [orderer.common.cluster.puller] probeEndpoint -> WARN 2e1 Failed connecting to {"CAs":[{"Expired":false,"Issuer":"self","Subject":"CN=tlsca.hu.com,O=hu.com,L=San Francisco,ST=California,C=US"}],"Endpoint":"orderer1.hu.com:7050"}: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 192.168.80.2:7050: connect: connection refused" channel=hu-channel
2021-07-06 02:02:06.194 UTC [orderer.common.cluster.puller] func1 -> WARN 2e2 Received error of type 'failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 192.168.80.2:7050: connect: connection refused"' from {"CAs":[{"Expired":false,"Issuer":"self","Subject":"CN=tlsca.hu.com,O=hu.com,L=San Francisco,ST=California,C=US"}],"Endpoint":"orderer1.hu.com:7050"} channel=hu-channel
2021-07-06 02:02:06.199 UTC [orderer.common.cluster.puller] probeEndpoint -> WARN 2e3 Failed connecting to {"CAs":[{"Expired":false,"Issuer":"self","Subject":"CN=tlsca.hu.com,O=hu.com,L=San Francisco,ST=California,C=US"}],"Endpoint":"orderer3.hu.com:7050"}: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 192.168.80.4:7050: connect: connection refused" channel=hu-channel
2021-07-06 02:02:06.199 UTC [orderer.common.cluster.puller] func1 -> WARN 2e4 Received error of type 'failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 192.168.80.4:7050: connect: connection refused"' from {"CAs":[{"Expired":false,"Issuer":"self","Subject":"CN=tlsca.hu.com,O=hu.com,L=San Francisco,ST=California,C=US"}],"Endpoint":"orderer3.hu.com:7050"} channel=hu-channel
错误原因:
初期分析是order节点之间不能通信,应该是端口设置问题,后来发现是相应的端口没有开启
解决方法:
通过指令开启相应端口
firewall-cmd --add-port=端口号/tcp --permanent
6 在启动docker-compose.yaml文件出现下列错误
ERROR: Failed to Setup IP tables: Unable to enable SKIP DNAT rule
错误原因:
查阅发现改变防火墙状态后需要重启docker服务
service docker restart
7 在创建通道时出现以下错误
Implicit policy evaluation failed - 0 sub-policies were satisfied, but this policy requires 1 of the 'Admins' sub-policies to be satisfied
错误原因:
经查阅资料,发现是生成创世区块时的channelID
和后续channelID
不能一致。
解决方法:
在生成创世区块的指令中将channelID
更改为system-channel
8 在打包链码时出现以下错误
错误原因:
初步分析应该是什么东西拒绝连接了,第一反应应该是go依赖被墙了。
解决方法:
更换go代理
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
9 重新启动网络创建通道时出现以下错误
Error: got unexpected status: BAD_REQUEST -- error applying config update to existing channel 'hu-channel': error authorizing update: error validating ReadSet: proposed update requires that key [Group] /Channel/Application be at version 0, but it is currently at version 1
错误原因:
虽然down掉网络了,但是还没有完全删干净,之前创建的通道其实还在。
解决方法:
docker rmi -f $(docker ps -aq)
docker volume prune
10 在安装链码出现以下错误
错误原因:
初步估计是因为下载不了依赖。
解决方法:
go mod tidy
go mod download
go vendor
11 使用Fabric-ca时出现以下错误
更进一步地,是执行下列命令,即使用管理员账号登录tls-ca服务器时出现错误
fabric-ca-client enroll -d -u https://tls-ca-admin:tls-ca-adminpw@0.0.0.0:7052
错误原因:
这里使用的是 tls 方式链接,因此必须配置tls证书
解决方法:
指定tls-ca证书
fabric-ca-client enroll -u https://tls-ca-admin:tls-ca-adminpw@0.0.0.0:7052 --tls.certfiles /usr/local/home/tls-ca/crypto/ca-cert.pem
12 test-network创建通道时出现下面错误
scripts/createChannel.sh: line 40: osnadmin: command not found
错误原因:
原因尚未可知,据网上查阅,好像因为我本地安装的时Fabric2.2
版本,而拉去的fabric-samples
是2.3
版本,2.3
版本有个新改动,所以会引起下列错误
解决方法:
将fabric-samples
切换至v2.2.2
版本即可
git checkout v2.2.2