安装方法详见:https://github.com/hyperledger/caliper
hyperledger caliper 使用过程的一些坑以及解决办法
# create mychannel......
ok 1 created mychannel successfully
# Sleep 5s......
# Join channel......
# join mychannel
not ok 2 Failed to join peers, TypeError: Cannot read property 'getConnectivityState' of undefined at EventHub._checkConnection (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/fabric-client/lib/EventHub.js:479:39) at EventHub.registerBlockEvent (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/fabric-client/lib/EventHub.js:658:8) at Promise (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/join-channel.js:139:20) at new Promise () at eventhubs.forEach (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/join-channel.js:136:29) at Array.forEach () at Client.newDefaultKeyValueStore.then.then.then.then (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/join-channel.js:135:19) at
---
operator: fail
at: channels.reduce.then.catch (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/join-channel.js:215:19)
stack: |-
Error: Failed to join peers, TypeError: Cannot read property 'getConnectivityState' of undefined
at EventHub._checkConnection (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/fabric-client/lib/EventHub.js:479:39)
at EventHub.registerBlockEvent (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/fabric-client/lib/EventHub.js:658:8)
at Promise (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/join-channel.js:139:20)
at new Promise ()
at eventhubs.forEach (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/join-channel.js:136:29)
at Array.forEach ()
at Client.newDefaultKeyValueStore.then.then.then.then (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/join-channel.js:135:19)
at
at Test.assert [as _assert] (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/tape/lib/test.js:224:54)
at Test.bound [as _assert] (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/tape/lib/test.js:76:32)
at Test.fail (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/tape/lib/test.js:317:10)
at Test.bound [as fail] (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/tape/lib/test.js:76:32)
at channels.reduce.then.catch (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/join-channel.js:215:19)
at
...
fabric.init() failed, Error: Fabric: Join channel failed
at channels.reduce.then.catch (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/join-channel.js:216:31)
at
[Transaction Info] - Submitted: 0 Succ: 0 Fail:0 Unfinished:0
unexpected error, Error: Fabric: Join channel failed
at channels.reduce.then.catch (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/join-channel.js:216:31)
at
docker-compose -f network/fabric/simplenetwork/docker-compose.yaml down;docker rm $(docker ps -aq);docker rmi $(docker images dev* -q)
/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/fabric-client/lib/EventHub.js:308
if(self._stream) state = self._stream.call.channel_.getConnectivityState();
^
TypeError: Cannot read property 'getConnectivityState' of undefined
at ClientDuplexStream. (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/fabric-client/lib/EventHub.js:308:56)
at emitOne (events.js:116:13)
at ClientDuplexStream.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at ClientDuplexStream.Readable.push (_stream_readable.js:208:10)
at Object.onReceiveMessage (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/grpc/src/client_interceptors.js:1276:19)
at InterceptingListener.recvMessageWithContext (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/grpc/src/client_interceptors.js:603:19)
at /Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/grpc/src/client_interceptors.js:702:14
解决方法:
使用grpc version 1.10.1 代替之前的1.13.1版本
npm install [email protected]
# create mychannel......
not ok 1 Failed to create channels Error: create status is BAD_REQUEST at channel.organizations.reduce.then.then.then (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/create-channel.js:145:43) at at process._tickCallback (internal/process/next_tick.js:188:7)
---
operator: fail
at: channels.reduce.then.then.catch (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/create-channel.js:159:19)
stack: |-
Error: Failed to create channels Error: create status is BAD_REQUEST
at channel.organizations.reduce.then.then.then (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/create-channel.js:145:43)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
at Test.assert [as _assert] (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/tape/lib/test.js:224:54)
at Test.bound [as _assert] (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/tape/lib/test.js:76:32)
at Test.fail (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/tape/lib/test.js:317:10)
at Test.bound [as fail] (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/tape/lib/test.js:76:32)
at channels.reduce.then.then.catch (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/create-channel.js:159:19)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
...
fabric.init() failed, Error: Fabric: Create channel failed
at channels.reduce.then.then.catch (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/create-channel.js:160:31)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
[Transaction Info] - Submitted: 0 Succ: 0 Fail:0 Unfinished:0
unexpected error, Error: Fabric: Create channel failed
at channels.reduce.then.then.catch (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/create-channel.js:160:31)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
docker-compose -f network/fabric/simplenetwork/docker-compose.yaml down;docker rm $(docker ps -aq);docker rmi $(docker images dev* -q)```
解决办法:
和之前搭建fabric环境遇到的问题一样,BAD_REQUEST 经常是当前要创建的channel 已经存在所以会出现这个错误,
我们可以通过docker rm -f $(docker ps -q -a)
移除之前的容器,但是如果不是channnel 已存在的问题 ,暂时就不知道怎么解决了
# Instantiate chaincode......
error: [Peer.js]: sendProposal - timed out after:120000
error: [Peer.js]: sendProposal - timed out after:120000
error: [Peer.js]: sendProposal - timed out after:120000
error: [Peer.js]: sendProposal - timed out after:120000
error: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: REQUEST_TIMEOUT
at Timeout._onTimeout (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/fabric-client/lib/Peer.js:124:19)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
error: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: REQUEST_TIMEOUT
at Timeout._onTimeout (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/fabric-client/lib/Peer.js:124:19)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
error: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: REQUEST_TIMEOUT
at Timeout._onTimeout (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/fabric-client/lib/Peer.js:124:19)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
error: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: REQUEST_TIMEOUT
at Timeout._onTimeout (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/fabric-client/lib/Peer.js:124:19)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
not ok 4 Failed to instantiate chaincodes, Error: Failed to send instantiate due to error: Error: Failed to send instantiate Proposal or receive valid response. Response null or status is not 200. exiting... at Client.newDefaultKeyValueStore.then.then.then.then (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/e2eUtils.js:372:19) at at process._tickCallback (internal/process/next_tick.js:188:7) at Client.newDefaultKeyValueStore.then.then.then.then.then (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/e2eUtils.js:385:15) at at process._tickCallback (internal/process/next_tick.js:188:7)
---
operator: fail
at: chaincodes.reduce.then.catch (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/instantiate-chaincode.js:60:19)
stack: |-
Error: Failed to instantiate chaincodes, Error: Failed to send instantiate due to error: Error: Failed to send instantiate Proposal or receive valid response. Response null or status is not 200. exiting...
at Client.newDefaultKeyValueStore.then.then.then.then (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/e2eUtils.js:372:19)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
at Client.newDefaultKeyValueStore.then.then.then.then.then (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/e2eUtils.js:385:15)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
at Test.assert [as _assert] (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/tape/lib/test.js:224:54)
at Test.bound [as _assert] (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/tape/lib/test.js:76:32)
at Test.fail (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/tape/lib/test.js:317:10)
at Test.bound [as fail] (/Users/rjj/go/src/github.com/hyperledger/caliper/node_modules/tape/lib/test.js:76:32)
at chaincodes.reduce.then.catch (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/instantiate-chaincode.js:60:19)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
...
fabric.installSmartContract() failed, Error: Fabric: instantiate chaincodes failed
at chaincodes.reduce.then.catch (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/instantiate-chaincode.js:61:31)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
[Transaction Info] - Submitted: 0 Succ: 0 Fail:0 Unfinished:0
unexpected error, Error: Fabric: instantiate chaincodes failed
at chaincodes.reduce.then.catch (/Users/rjj/go/src/github.com/hyperledger/caliper/src/fabric/instantiate-chaincode.js:61:31)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
docker-compose -f network/fabric/simplenetwork/docker-compose.yaml down;docker rm $(docker ps -aq);docker rmi $(docker images dev* -q)
解决办法:
这个问题算是比较坑的了,在网上找了很久,看到github 有一个一样的问题
https://github.com/hyperledger/caliper/issues/137
有一条评论提到,因为机器性能问题,开启的peer 较多,两分钟不足以在本机上实例化chaincode 但是照着上面的方式修改了
文件:github.com/hyperledger/caliper/src/fabric/e2eUtils.js#211
中的request_time 时间
运行后还是没有解决这个问题,经过一天时间,巧合看到一篇文章提到修改文件:github.com/hyperledger/caliper/node_modules/fabric-client/config/default.json
配置文件中的request_time 运行成功