Fabric节点SDK使用服务发现功能

时间:2018-12-12 12:22:46

标签: node.js hyperledger-fabric hyperledger hyperledger-fabric-sdk-js

我尝试使用结构节点sdk调用Fabric v1.2的服务发现功能,但出现以下错误:

case GET_FILES : 
  return{
    ...state,
    file: action.payload
  }

但是,我完全可以确保已经实例化了链码,如果不使用OnEnableDisplay = (event) => { this.props.filesDownload(attachements_call); };

,我通常可以调用它。

这是我的服务发现代码:

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);

1 个答案:

答案 0 :(得分:0)

我自己解决了。那可能是某种网络错误。

现在,我将peer1.org1.example.compeer0.org2.example.compeer1.org2.example.com的端口更改为8051、9051、10051、11051。根据节点sdk official doc,我设置了{{1 }}。

这是我可能适用的代码:

asLocalhost = true

希望这可以帮助其他人。