记录开发过程中遇到的各种错误和解决办法
-
创建通道的时候遇到的错误:
Error: got unexpected status: FORBIDDEN -- Failed to reach implicit threshold of 1 sub-policies, required 1 remaining: permission denied
Peer加入通道时遇到的错误,此时Peer可以安装链码,但是不能实例化:
2018-10-09 10:20:14.228 CST [blocksProvider] DeliverBlocks -> ERRO 386 [fabricchannel] Got error &{FORBIDDEN} 2018-10-09 10:53:06.071 CST [common/deliver] deliverBlocks -> WARN 013 [channel: fabricchannel] Client authorization revoked for deliver request from 127.0.0.1:48986: Failed to reach implicit threshold of 1 sub-policies, required 1 remaining: permission denied
我的解决办法:
按照以上思路解决再三检查配置文件之后,仍未解决,最终将crypto-config.yaml中的PeerOrgs->EnableNodeOUs设为true,然后问题解决。目前还不能非常肯定问题的原因,但是感觉还是和账户管理相关。
其他可能的解决思路:
- 检查配置文件中各种MSPID的对应是否一致,比如core.yaml中的“localMspId”和orderer.yaml中的“LocalMSPID”必须和configtx.yaml中的ID一致。
- 检查各种证书路径是否正确。如果设置了环境变量也要检查。
- 检查configtx.yaml中“Organizations”下组织的权限规则设置是否有问题。
- 每次修改完成配置文件之后,删除core.yaml,orderer.yaml,configtx.yaml,crypto-config.yaml以外的所有文件,以防残余文件产生冲突。
-
启动orderer start的时候报错:
panic: Error creating channelconfig bundle: initializing configtx manager failed: bad channel ID: channel ID 'Ordererchannel' contains illegal characters
创建orderer创世块的时候,-channelID 后边接的通道名不能包含大写。该处通道名,不能和peer channel create 创建的通道名一样,不然也会出现 1 中的错误
got unexpected status: FORBIDDEN
。$ configtxgen -profile OrdererChannel -outputBlock genesisblock -channelID ordererchannel
-
多Peer节点操作链码时报错“chaincode fingerprint mismatch: data mismatch”
Error: endorsement failure during query. response: status:500 message:"failed to execute transaction bed01c78367286e45aafef9e85764993b5315a63f686974c7c70055512365118: [channel atlchannel] failed to get chaincode container info for cc:1.0: could not get chaincode code: chaincode fingerprint mismatch: data mismatch"
解决方案,先打包链码再在各个peer安装链码安装包:
$ peer chaincode package -n cc -p github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd -v 1.02 ccpack.out // 打包链码安装包 $ peer chaincode install ccpack.out // 安装链码。注意:这里不需要-n -v -p 的参数,生成package的时候已经指定这些参数了。 $ peer chaincode update -o 148.70.109.243:7050 -C atlchannel -n cc -v 1.02 -c '{"Args":["init","a","100","b","200"]}' // (可选)升级链码
-
执行"peer chaincode query"无反应。
问题背景:搭建两个Peer节点,第一个Peer安装完Chaincode测试没有问题,第二个Peer安装完Chaincode之后,执行"peer chaincode query" 等了很久没有反应。
解决方案:什么也没做,去吃了个饭,回来居然没问题了,可以查询出结果。据说使用SDK查询的时候,如果没有同步完成会有返回信息,但是CLI没有。
问题反思:query查询的是本地的内容,应该和网络没什么关系,一致查不出结果,很可能是peer的账本文件没有同步完成导致的。以后再遇到此类问题应该注意的地方:
configtx.yaml->Organizations->SampleOrg->AnchorPeers 这个值应该要设置,Anchor Peer是和其他组织节点通信的节点,可能对同步账本有影响。
core.yaml->peer->gossip->bootstrap 这里配置gossip初始的连接地址,合理的配置可能会影响账本同步的速度。
core.yaml->peer->gossip->externalEndpoint 设置这里的ip可以让外部组织的peer找到该peer。不太确定具体作用,但是可能会影响到该peer被其他peer发现。
-
裸机部署多节点(即不使用Docker),本想通过7051和8051部署两个Peer,但是
peer node start
的时候端口冲突报错。Error: failed to initialize operations subystems: listen tcp 127.0.0.1:9443: bind: address already in use
看来单机多节点部署,只能使用docker了。
-
peer,orderer 启用 TLS,发送交易时报错:
// 执行如下命令时 peer channel create -o 127.0.0.1:7050 -c atlchannel -f atlchannel.tx --tls true --cafile crypto-config/ordererOrganizations/orga.atlchain.com/orderers/orderer.orga.atlchain.com/tls/server.crt // peer cli 报如下错误 Error: failed to create deliver client: orderer client failed to connect to 127.0.0.1:7050: failed to create new connection: context deadline exceeded // orderer 报如下错误 2019-03-29 16:27:19.308 CST [core.comm] ServerHandshake -> ERRO 00f TLS handshake failed with error remote error: tls: bad certificate {"server": "Orderer", "remote address": "127.0.0.1:56784"}
说明证书有问题,然后将日志级别调整为 DEBUG (
export FABRIC_LOGGING_SPEC=DEBUG
然后重新启动节点),在 peer cli 你会看到如下错误:2019-03-29 17:02:38.781 CST [grpc] createTransport -> DEBU 03d grpc: addrConn.createTransport failed to connect to {127.0.0.1:7050 0
}. Err :connection error: desc = "transport: authentication handshake failed: x509: cannot validate certificate for 127.0.0.1 because it doesn't contain any IP SANs". Reconnecting... 该报错说明,证书中没有包含 IP 的说明 “doesn't contain any IP SANs” ,至此问题已明了。我在执行的时候 -o 的参数是一个 IP 地址,但是证书中不包含这个 IP 。
解决方案: 在指定 orderer 的地址时将 IP 改为 orderer 的域名,同时在 hosts 文件中修改域名的映射 IP 即可。
当然,出现
tls: bad certificate
报错还会因为其他原因引起,比如说指定了错误的证书,TLS 功能未正确开启等。 -
节点使用Couchdb报错:
[200~Error calling CouchDB CreateDatabaseIfNotExist(for system dbName: _users, error: error decoding response body: json: cannot unmarshal string into Go struct field DBInfo.purge_seq of type int)]
peer没有权限创建Couchdb已存在的表。
解决方案:将Couchdb 2.3 版本切换到2.1.1后解决。
切换方法,基于Docker:
$ docker pull couchdb:2.1.1 $ docker run -p 5984:5984 -d couchdb:2.1.1
然后打开网址 http://127.0.0.1:5984/_utils/ 设置管理员用户名密码即可。
-
提交交易中包含较大数据的时候报错:
[2019-01-30 18:45:50.755] [ERROR] invoke-chaincode - REQUEST_TIMEOUT:localhost:7051 [2019-01-30 18:45:50.755] [ERROR] invoke-chaincode - Error: ChannelEventHub has been shutdown at ChannelEventHub.disconnect (/home/chengyang/Documents/ATL/ATLab-ATLChain/node_modules/fabric-client/lib/ChannelEventHub.js:516:21) at Timeout.setTimeout (/home/chengyang/Documents/ATL/ATLab-ATLChain/app/invoke-transaction.js:89:10) at ontimeout (timers.js:475:11) at tryOnTimeout (timers.js:310:5) at Timer.listOnTimeout (timers.js:270:5) [2019-01-30 18:45:50.755] [ERROR] invoke-chaincode - Error: ChannelEventHub has been shutdown at ChannelEventHub.disconnect (/home/chengyang/Documents/ATL/ATLab-ATLChain/node_modules/fabric-client/lib/ChannelEventHub.js:516:21) at Timeout.setTimeout (/home/chengyang/Documents/ATL/ATLab-ATLChain/app/invoke-transaction.js:89:10) at ontimeout (timers.js:475:11) at tryOnTimeout (timers.js:310:5) at Timer.listOnTimeout (timers.js:270:5) [2019-01-30 18:45:50.755] [ERROR] invoke-chaincode - Failed to invoke chaincode. cause:Error: ChannelEventHub has been shutdown (node:8938) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 6): Error: Failed to invoke chaincode. cause:Error: ChannelEventHub has been shutdown
问题描述:我在提交的交易中加入了一个图片,经过简单测试,当图片大小超过 100K 的时候报该错误(但是偶尔也可以提交成功)。
解决方案:尝试减小交易中的数据量。目前未能确定每次提交的时候是如何限制提交数据的大小的,但是从报错内容来看,应该不是直接显示提案的大小,可能是从响应时间上来限制的,数据量大时响应时间长,就超时报错。
-
byfn 运行时报错:
运行
./byfn.sh up
的时候,报如下错误:Having all peers join the channel... + peer channel join -b mychannel.block + res=1 + set +x Error: error getting endorser client for channel: endorser client failed to connect to peer0.org1.example.com:7051: failed to create new connection: context deadline exceeded peer0.org1 failed to join the channel, Retry after 3 seconds + peer channel join -b mychannel.block + res=1 + set +x Error: error getting endorser client for channel: endorser client failed to connect to peer0.org1.example.com:7051: failed to create new connection: context deadline exceeded
peer 节点容器启动后又关闭,导致执行 peer 节点加入 channel 的命令时不成功。查看 peer 容器日志
docker logs peer0.org1.example.com
如下:2019-02-21 08:12:05.380 UTC [nodeCmd] serve -> INFO 001 Starting peer: Version: 1.4.0 Commit SHA: d700b43 Go version: go1.11.1 OS/Arch: linux/amd64 Chaincode: Base Image Version: 0.4.14 Base Docker Namespace: hyperledger Base Docker Label: org.hyperledger.fabric Docker Namespace: hyperledger 2019-02-21 08:12:05.380 UTC [ledgermgmt] initialize -> INFO 002 Initializing ledger mgmt 2019-02-21 08:12:05.380 UTC [kvledger] NewProvider -> INFO 003 Initializing ledger provider 2019-02-21 08:12:05.451 UTC [kvledger] NewProvider -> INFO 004 ledger provider Initialized 2019-02-21 08:12:05.513 UTC [ledgermgmt] initialize -> INFO 005 ledger mgmt initialized 2019-02-21 08:12:05.514 UTC [peer] func1 -> INFO 006 Auto-detected peer address: 192.168.128.3:7051 2019-02-21 08:12:05.514 UTC [peer] func1 -> INFO 007 Returning peer0.org1.example.com:7051 2019-02-21 08:12:05.514 UTC [peer] func1 -> INFO 008 Auto-detected peer address: 192.168.128.3:7051 2019-02-21 08:12:05.515 UTC [peer] func1 -> INFO 009 Returning peer0.org1.example.com:7051 2019-02-21 08:12:05.517 UTC [nodeCmd] serve -> INFO 00a Starting peer with TLS enabled 2019-02-21 08:12:05.520 UTC [nodeCmd] computeChaincodeEndpoint -> INFO 00b Entering computeChaincodeEndpoint with peerHostname: peer0.org1.example.com 2019-02-21 08:12:05.521 UTC [nodeCmd] computeChaincodeEndpoint -> INFO 00c Exit with ccEndpoint: peer0.org1.example.com:7052 2019-02-21 08:12:05.521 UTC [nodeCmd] createChaincodeServer -> WARN 00d peer.chaincodeListenAddress is not set, using peer0.org1.example.com:7052 2019-02-21 08:12:05.531 UTC [sccapi] registerSysCC -> INFO 00e system chaincode lscc(github.com/hyperledger/fabric/core/scc/lscc) registered 2019-02-21 08:12:05.531 UTC [sccapi] registerSysCC -> INFO 00f system chaincode cscc(github.com/hyperledger/fabric/core/scc/cscc) registered 2019-02-21 08:12:05.531 UTC [sccapi] registerSysCC -> INFO 010 system chaincode qscc(github.com/hyperledger/fabric/core/scc/qscc) registered 2019-02-21 08:12:05.531 UTC [sccapi] registerSysCC -> INFO 011 system chaincode (+lifecycle,github.com/hyperledger/fabric/core/chaincode/lifecycle,true) disabled 2019-02-21 08:12:05.538 UTC [gossip.service] func1 -> INFO 012 Initialize gossip with endpoint peer0.org1.example.com:7051 and bootstrap set [peer1.org1.example.com:7051] 2019-02-21 08:12:05.549 UTC [gossip.gossip] NewGossipService -> INFO 013 Creating gossip service with self membership of Endpoint: peer0.org1.example.com:7051, InternalEndpoint: peer0.org1.example.com:7051, PKI-ID: 95ea1f50253cc23fe5f809fbbc49596dd42c3502f4848ce3003ea27464236548, Metadata: 2019-02-21 08:12:05.553 UTC [gossip.gossip] start -> INFO 014 Gossip instance peer0.org1.example.com:7051 started 2019-02-21 08:12:05.553 UTC [sccapi] deploySysCC -> INFO 015 system chaincode lscc/(github.com/hyperledger/fabric/core/scc/lscc) deployed ** fatal error: unexpected signal during runtime execution ** [signal SIGSEGV: segmentation violation code=0x1 addr=0x63 pc=0x7f661833c259] runtime stack: runtime.throw(0x123f0ff, 0x2a) /opt/go/src/runtime/panic.go:608 +0x72 runtime.sigpanic() /opt/go/src/runtime/signal_unix.go:374 +0x2f2 goroutine 75 [syscall]: runtime.cgocall(0xe1bdc0, 0xc0002c6600, 0x29) /opt/go/src/runtime/cgocall.go:128 +0x5e fp=0xc0002c65c8 sp=0xc0002c6590 pc=0x4039ee net._C2func_getaddrinfo(0xc0003765c0, 0x0, 0xc00032ec00, 0xc00000e240, 0x0, 0x0, 0x0) _cgo_gotypes.go:92 +0x55 fp=0xc0002c6600 sp=0xc0002c65c8 pc=0x615b95 net.cgoLookupIPCNAME.func1(0xc0003765c0, 0x0, 0xc00032ec00, 0xc00000e240, 0x17, 0x17, 0xbf13b535a108855c) /opt/go/src/net/cgo_unix.go:149 +0x131 fp=0xc0002c6648 sp=0xc0002c6600 pc=0x61b2b1 net.cgoLookupIPCNAME(0xc00004415b, 0x16, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0) /opt/go/src/net/cgo_unix.go:149 +0x153 fp=0xc0002c6738 sp=0xc0002c6648 pc=0x617153 net.cgoIPLookup(0xc000349140, 0xc00004415b, 0x16) /opt/go/src/net/cgo_unix.go:201 +0x4d fp=0xc0002c67c8 sp=0xc0002c6738 pc=0x61780d runtime.goexit() /opt/go/src/runtime/asm_amd64.s:1333 +0x1 fp=0xc0002c67d0 sp=0xc0002c67c8 pc=0x45dc81 created by net.cgoLookupIP /opt/go/src/net/cgo_unix.go:211 +0xad
发现有一条报错
fatal error: unexpected signal during runtime execution
。解决方案:
在 docker-compose-cli.yaml 中 cli 容器下,添加环境变量 GODEBUG=netdns=go,在 base/peer-base.yaml 中 peer-base 容器下,添加环境变量 GODEBUG=netdns=go
参考文献: https://yq.aliyun.com/articles/238940
解决方法二:如果以上方法不能解决问题,尝试修改 /etc/resolv.conf 文件:
注释掉 options 的行,我修改后的文件如下,不同系统有些不同:
nameserver 127.0.0.53 # options edns0
使用Fabric java 链码,使用Fabric SDK java 以多线程的方式访问Peer 节点,当线程数大于等于3时,invoke和query操作频繁报错,报错内容如下:
peer日志:
2020-06-28 06:16:16.481 UTC [endorser] SimulateProposal -> ERRO 35ecc [txchannel][72ec0e0f] failed to invoke chaincode name:"supermapcc" , error: transaction returned with failure: Failed to submit task for processing
github.com/hyperledger/fabric/core/chaincode.processChaincodeExecutionResult
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:266
github.com/hyperledger/fabric/core/chaincode.(*ChaincodeSupport).Execute
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:240
github.com/hyperledger/fabric/core/endorser.(*SupportImpl).Execute
/opt/gopath/src/github.com/hyperledger/fabric/core/endorser/support.go:147
github.com/hyperledger/fabric/core/endorser.(*Endorser).callChaincode
/opt/gopath/src/github.com/hyperledger/fabric/core/endorser/endorser.go:146
github.com/hyperledger/fabric/core/endorser.(*Endorser).SimulateProposal
/opt/gopath/src/github.com/hyperledger/fabric/core/endorser/endorser.go:247
github.com/hyperledger/fabric/core/endorser.(*Endorser).ProcessProposal
/opt/gopath/src/github.com/hyperledger/fabric/core/endorser/endorser.go:500
github.com/hyperledger/fabric/core/handlers/auth/filter.(*expirationCheckFilter).ProcessProposal
/opt/gopath/src/github.com/hyperledger/fabric/core/handlers/auth/filter/expiration.go:61
github.com/hyperledger/fabric/core/handlers/auth/filter.(*filter).ProcessProposal
/opt/gopath/src/github.com/hyperledger/fabric/core/handlers/auth/filter/filter.go:32
github.com/hyperledger/fabric/protos/peer._Endorser_ProcessProposal_Handler.func1
/opt/gopath/src/github.com/hyperledger/fabric/protos/peer/peer.pb.go:169
github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1
/opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:31
github.com/hyperledger/fabric/core/comm.(*Throttle).UnaryServerIntercptor
/opt/gopath/src/github.com/hyperledger/fabric/core/comm/throttle.go:54
github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1
/opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:34
github.com/hyperledger/fabric/common/grpclogging.UnaryServerInterceptor.func1
/opt/gopath/src/github.com/hyperledger/fabric/common/grpclogging/server.go:91
github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1
/opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:34
github.com/hyperledger/fabric/common/grpcmetrics.UnaryServerInterceptor.func1
/opt/gopath/src/github.com/hyperledger/fabric/common/grpcmetrics/interceptor.go:30
github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1
/opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:39
github.com/hyperledger/fabric/protos/peer._Endorser_ProcessProposal_Handler
/opt/gopath/src/github.com/hyperledger/fabric/protos/peer/peer.pb.go:171
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*Server).processUnaryRPC
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/server.go:982
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*Server).handleStream
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/server.go:1208
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*Server).serveStreams.func1.1
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/server.go:686
runtime.goexit
/opt/go/src/runtime/asm_amd64.s:1337
链码容器报错:
06:52:31:949 WARNING org.hyperledger.fabric.shim.impl.InnvocationTaskManager newTask Failed to submit task d1c790e054cb122ce332679797503290fabe02a82b0b4f8033bd9129376b006eTask java.util.concurrent.CompletableFuture$AsyncRun@3ddcf2df rejected from org.hyperledger.fabric.shim.impl.InnvocationTaskExecutor@a2db0e08[Running, pool size = 1, active threads = 1, queued tasks = 1, completed tasks = 5]
java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.CompletableFuture$AsyncRun@3ddcf2df rejected from org.hyperledger.fabric.shim.impl.InnvocationTaskExecutor@a2db0e08[Running, pool size = 1, active threads = 1, queued tasks = 1, completed tasks = 5]
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2063)
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:830)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1379)
at java.util.concurrent.CompletableFuture.asyncRunStage(CompletableFuture.java:1640)
at java.util.concurrent.CompletableFuture.runAsync(CompletableFuture.java:1858)
at org.hyperledger.fabric.shim.impl.InnvocationTaskManager.newTask(InnvocationTaskManager.java:226)
at org.hyperledger.fabric.shim.impl.InnvocationTaskManager.handleMsg(InnvocationTaskManager.java:172)
at org.hyperledger.fabric.shim.impl.InnvocationTaskManager.onChaincodeMessage(InnvocationTaskManager.java:141)
at org.hyperledger.fabric.shim.impl.ChaincodeSupportClient$$Lambda$9.00000000B00CACE0.accept(Unknown Source)
at org.hyperledger.fabric.shim.impl.ChaincodeSupportClient$1.onNext(ChaincodeSupportClient.java:86)
at org.hyperledger.fabric.shim.impl.ChaincodeSupportClient$1.onNext(ChaincodeSupportClient.java:82)
at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onMessage(ClientCalls.java:429)
at io.grpc.ForwardingClientCallListener.onMessage(ForwardingClientCallListener.java:33)
at io.grpc.ForwardingClientCallListener.onMessage(ForwardingClientCallListener.java:33)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInternal(ClientCallImpl.java:599)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInContext(ClientCallImpl.java:584)
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:819)
报错原因:
Fabric Java 链码的依赖 fabric-chaincode-java.fabric-chaincode-shim 1.4.4 版本有bug,线程池参数设置有问题,请使用1.4.5及以上版本,Fabric版本和fabric-chaincode-java版本不必一致。即如下依赖:
org.hyperledger.fabric-chaincode-java
fabric-chaincode-shim
1.4.4
compile
github的changelog中也有更新说明 https://github.com/hyperledger/fabric-chaincode-java/blob/release-1.4/CHANGELOG.md#v145