首页 > 解决方案 > 对等链代码实例化时超时已过期

问题描述

我使用 CA 创建一个多节点结构网络。

我的代码是这样的:https ://github.com/fnpac/fabric-web/blob/master/fabric-ca/scripts/run-fabric.sh

对等配置:https ://github.com/fnpac/fabric-web/blob/ce7929e59b0ba1bc3a55d16ea66fa08131c294dc/fabric-ca/makeDocker.sh#L207-L272

当我实例化chaincode时,会报如下错误:</p>

##### 2018-05-22 09:14:49 Instantiating chaincode on peer1-org2 ...
2018-05-22 09:14:49.374 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-05-22 09:14:49.375 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-05-22 09:14:49.382 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-05-22 09:14:49.382 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-05-22 09:14:49.383 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
2018-05-22 09:14:49.383 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0AAB090A6708031A0C0889BF8FD80510...324D53500A04657363630A0476736363 
2018-05-22 09:14:49.383 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: 754973C8F271A44D0933CD73D9219A51DA5FDD2E84938E6EA10F9DA3E2981692 
Error: Error endorsing chaincode: rpc error: code = Unknown desc = timeout expired while starting chaincode mycc:1.0(networkid:dev,peerid:peer1-org2,tx:a93b69c5243e04171ca16188e733d03671d93bb606819b101125642410d0c911)
Usage:
  peer chaincode instantiate [flags]

Flags:
  -C, --channelID string            The channel on which this command should be executed

和订购者的日志:

2018-05-22 09:19:49.391 UTC [dockercontroller] stopInternal -> DEBU 5e1 Kill container dev-peer1-org2-mycc-1.0 (API error (409): {"message":"Cannot kill container: dev-peer1-org2-mycc-1.0: Container 9751bded21b329c2b516386d78fd7a751833fccdde5104a96dcf3f22304ff0d8 is not running"}
)
2018-05-22 09:19:49.400 UTC [dockercontroller] stopInternal -> DEBU 5e2 Removed container dev-peer1-org2-mycc-1.0
2018-05-22 09:19:49.400 UTC [container] unlockContainer -> DEBU 5e3 container lock deleted(dev-peer1-org2-mycc-1.0)
2018-05-22 09:19:49.400 UTC [chaincode] func1 -> DEBU 5e4 chaincode mycc:1.0 launch seq completed
2018-05-22 09:19:49.400 UTC [chaincode] Launch -> ERRO 5e5 launchAndWaitForRegister failed: timeout expired while starting chaincode mycc:1.0(networkid:dev,peerid:peer1-org2,tx:a93b69c5243e04171ca16188e733d03671d93bb606819b101125642410d0c911)
github.com/hyperledger/fabric/core/chaincode.(*ChaincodeSupport).launchAndWaitForRegister
    /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:569
github.com/hyperledger/fabric/core/chaincode.(*ChaincodeSupport).Launch
    /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:731
github.com/hyperledger/fabric/core/chaincode.Execute
    /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/exectransaction.go:45
github.com/hyperledger/fabric/core/endorser.(*SupportImpl).Execute
    /opt/gopath/src/github.com/hyperledger/fabric/core/endorser/support.go:83
github.com/hyperledger/fabric/core/endorser.(*Endorser).callChaincode
    /opt/gopath/src/github.com/hyperledger/fabric/core/endorser/endorser.go:164
github.com/hyperledger/fabric/core/endorser.(*Endorser).simulateProposal
    /opt/gopath/src/github.com/hyperledger/fabric/core/endorser/endorser.go:265
github.com/hyperledger/fabric/core/endorser.(*Endorser).ProcessProposal
    /opt/gopath/src/github.com/hyperledger/fabric/core/endorser/endorser.go:491
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:31
github.com/hyperledger/fabric/protos/peer._Endorser_ProcessProposal_Handler
    /opt/gopath/src/github.com/hyperledger/fabric/protos/peer/peer.pb.go:112
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:781
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:981
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:551
runtime.goexit
    /opt/go/src/runtime/asm_amd64.s:2337
2018-05-22 09:19:49.400 UTC [endorser] callChaincode -> DEBU 5e6 [mychannel][a93b69c5] Exit
2018-05-22 09:19:49.400 UTC [endorser] simulateProposal -> ERRO 5e7 [mychannel][a93b69c5] failed to invoke chaincode name:"lscc" , error: timeout expired while starting chaincode mycc:1.0(networkid:dev,peerid:peer1-org2,tx:a93b69c5243e04171ca16188e733d03671d93bb606819b101125642410d0c911)
github.com/hyperledger/fabric/core/chaincode.(*ChaincodeSupport).launchAndWaitForRegister
    /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:569
github.com/hyperledger/fabric/core/chaincode.(*ChaincodeSupport).Launch
    /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:731

我该如何解决?

标签: hyperledger-fabricblockchain

解决方案


我已经修好了。

这是因为我peer chaincode instantiate在另一台机器上执行操作,我应该在指定节点的机器上执行它。

例如:

 # Instantiate the chain code on the first peer node of the first peer organization
 makePolicy
 initPeerVars ${PORGS[0]} 1
 switchToAdminIdentity
 Logr "Instantiating chaincode on $PEER_HOST ..."
 Peer chaincode instantiate -C $CHANNEL_NAME -n mycc -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "$POLICY" $ORDERER_CONN_ARGS

上面的脚本应该在第一个peer组织的第一个peer节点的机器上执行。如果在其他机器上执行脚本会超时


推荐阅读