我尝试使用fabric node sdk调用Fabric v1.2的服务发现功能,但出现以下错误:
2018-12-12 11:51:26.413 UTC [endorser] callChaincode -> INFO 05d [mychannel][16a59ced] Entry chaincode: name:"mycc"
2018-12-12 11:51:30.138 UTC [chaincode] ProcessStream -> ERRO 05e handling chaincode support stream: rpc error: code = Canceled desc = context canceled
receive failed
github.com/hyperledger/fabric/core/chaincode.(*Handler).ProcessStream
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/handler.go:408
github.com/hyperledger/fabric/core/chaincode.(*ChaincodeSupport).HandleChaincodeStream
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:182
github.com/hyperledger/fabric/core/chaincode.(*ChaincodeSupport).Register
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:187
github.com/hyperledger/fabric/core/chaincode/accesscontrol.(*interceptor).Register
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/accesscontrol/interceptor.go:57
github.com/hyperledger/fabric/protos/peer._ChaincodeSupport_Register_Handler
/opt/gopath/src/github.com/hyperledger/fabric/protos/peer/chaincode_shim.pb.go:1066
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*Server).processStreamingRPC
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/server.go:1160
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:1253
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:680
runtime.goexit
/opt/go/src/runtime/asm_amd64.s:2361
2018-12-12 11:52:00.041 UTC [endorser] callChaincode -> INFO 05f [mychannel][16a59ced] Exit chaincode: name:"mycc" (33628ms)
但是,我完全可以确保我已经实例化了我的链码,如果我不使用,我通常可以调用它service discovery.
这是我的服务发现代码:
let client = await helper.getClientForOrg(orgName);
let channel = client.newChannel(channelName);
channel.addPeer(client.getPeer("peer0.org1.example.com"));
await channel.initialize({discover:true, asLocalhost:true});
let request = {
chaincodeId: chaincodeName,
fcn: functionName,
args: args,
transientMap: transient
};
logger.debug("Make query");
let response_payloads = await channel.queryByChaincode(request);
我哪里错了?在我使用之前有一些代码service discovery
:
let client = await helper.getClientForOrg(orgName);
let channel = client.newChannel(channelName);
// assign orderer to channel
channel.addOrderer(client.getOrderer(ordererName));
// assign peers to channel
peers.forEach(function (peerName) {
channel.addPeer(client.getPeer(peerName));
});
let request = {
targets: peers,
chaincodeId: chaincodeName,
fcn: functionName,
args: args,
transientMap: transient
};
logger.debug("Make query");
let response_payloads = await channel.queryByChaincode(request);