hyperledger fabric-sample 运行 chaincode-docker-devmode 遇到的坑

安装了fabric的 Prerequisites 之后,按照http://hyperledger-fabric.readthedocs.io/en/latest/chaincode4ade.html运行devmode,发现了一个问题.

1 cli节点上 peer chaincode install chaincode

2 cli节点上 peer chaincode instantiate 会报错,错误如下

handler not found for chaincode XXXX

浪费很多时间在这个问题上,因为步骤一是成功的,所以步骤2报告的错误很奇怪。后来仔细看了http://hyperledger-fabric.readthedocs.io/en/latest/chaincode4ade.html文档,发现这种情况下peer是使用了特殊的 --peer-chaincodedev = true启动的。

需要手动在chaincode节点上启动chaincode,启动的环境变量中 CORE_PEER_ADDRESS=peer:7052.端口号必须是7052,如果是7051或者7053都会启动报错。为什么会用7051呢,就是因为发现docker-compose-simple.yaml的配置中,有一行配置是 CORE_PEER_ADDRESS=peer:7051,而且网上很多博客上记录的也是7051,就用了7051作为环境变量的值启动chaincode,怎么尝试都不成功。

仔细查看官方资料http://hyperledger-fabric.readthedocs.io/en/latest/chaincode4ade.html,确实写的是7052.使用7052成功了。在cli 节点上 peer chaincode install --->peer chaincode instantiate--->peer chaincode invoke----->peer chaincode query 都是正常的。但是不明白为什么,使用 7052作为关键字在fabric的源代码目录search,果然找到了解释,答案就在fabric/simpleconfig/core.yaml中。贴在下面:

    # The Address at local network interface this Peer will listen on.
    # By default, it will listen on all network interfaces
    listenAddress: 0.0.0.0:7051

    # The endpoint this peer uses to listen for inbound chaincode connections.
    # If this is commented-out, the listen address is selected to be
    # the peer's address (see below) with port 7052
    # chaincodeListenAddress: 0.0.0.0:7052

    # The endpoint the chaincode for this peer uses to connect to the peer.
    # If this is not specified, the chaincodeListenAddress address is selected.
    # And if chaincodeListenAddress is not specified, address is selected from
    # peer listenAddress.
    # chaincodeAddress: 0.0.0.0:7052

    # When used as peer config, this represents the endpoint to other peers
    # in the same organization. For peers in other organization, see
    # gossip.externalEndpoint for more info.
    # When used as CLI config, this means the peer's endpoint to interact with
    address: 0.0.0.0:7051

当我们手动启动chaincode,设置的 CORE_PEER_ADDRESS 环境变量的目的是告诉chaincode如何连上peer,但是7051不是peer用来和chaincode通信的,7052端口才是。

看来有时候也不能在不知其所以然的情况下,盲目的baidu资料,这样可能会浪费很多时间。


  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值