小苏勇闯草台班 2025-05-28 20:42 采纳率: 100%
浏览 5
已结题

caliper测试grpc的ip被替换成localhost

Fabric2.2.14多机部署下,采用caliper0.5做测试,发现networks配置里的对每个节点指定的url: grpcs://172.21.0.10:7051没有被解析成功,最终发送是采用的是grpcs://localhost:7051,这是怎么回事?该怎么解决?请各位不吝赐教!谢谢!

img

具体网络配置内容如下

# networks/distributed-network.yaml
name: Fabric
version: "2.0.0"

caliper:
  blockchain: fabric

channels:
  - channelName: mychannel
    contracts:
      - id: basic

organizations:
  - mspid: Org1MSP
    identities:
      certificates:
      - name: 'User1'
        # admin: true
        clientPrivateKey:
          path: '/home/ubuntu/fabric-testing/distributed-network/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/keystore/priv_sk'
        clientSignedCert:
          path: '/home/ubuntu/fabric-testing/distributed-network/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/signcerts/User1@org1.example.com-cert.pem'
    connectionProfile:
      path: './networks/fabric/connection-org1.yaml'
      discover: true
# networks/fabric/connection-org1.yaml
name: Fabric
version: 1.0.0

organizations:
  Org1:
    mspid: Org1MSP
    peers:
      - peer0.org1.example.com
  Org2:
    mspid: Org2MSP
    peers:
      - peer0.org2.example.com

orderers:
  orderer.example.com:
    url: grpcs://172.21.0.8:7050
    grpcOptions:
    #   checkServerIdentity: () => { return null }  # 临时绕过证书验证(测试环境)
      ssl-target-name-override: orderer.example.com
      hostnameOverride: 172.21.0.8
    tlsCACerts:
      path: /home/ubuntu/fabric-testing/distributed-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt
  orderer2.example.com:
    url: grpcs://172.21.0.12:8050
    grpcOptions:
    #   checkServerIdentity: () => { return null }  # 临时绕过证书验证(测试环境)
      ssl-target-name-override: orderer2.example.com
      hostnameOverride: 172.21.0.12
    tlsCACerts:
      path: /home/ubuntu/fabric-testing/distributed-network/organizations/ordererOrganizations/example.com/orderers/orderer2.example.com/tls/ca.crt
  orderer3.example.com:
    url: grpcs://172.21.0.14:9050
    grpcOptions:
    #   checkServerIdentity: () => { return null }  # 临时绕过证书验证(测试环境)
      ssl-target-name-override: orderer3.example.com
      hostnameOverride: 172.21.0.14
    tlsCACerts:
      path: /home/ubuntu/fabric-testing/distributed-network/organizations/ordererOrganizations/example.com/orderers/orderer3.example.com/tls/ca.crt

peers:
  peer0.org1.example.com:
    url: grpcs://172.21.0.3:7051
    grpcOptions:
    #   checkServerIdentity: () => { return null }  # 临时绕过证书验证(测试环境)
      ssl-target-name-override: peer0.org1.example.com
      hostnameOverride: 172.21.0.3
    tlsCACerts:
      path: /home/ubuntu/fabric-testing/distributed-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt

  peer0.org2.example.com:
    url: grpcs://172.21.0.6:9051
    grpcOptions:
    #   checkServerIdentity: () => { return null }  # 临时绕过证书验证(测试环境)
      ssl-target-name-override: peer0.org2.example.com
      hostnameOverride: 172.21.0.6
    tlsCACerts:
      path: /home/ubuntu/fabric-testing/distributed-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
  • 写回答

6条回答 默认 最新

  • 小苏勇闯草台班 2025-05-28 23:02
    关注

    在github仓库issue找到答案了。
    https://github.com/hyperledger-caliper/caliper/issues/1216
    多机部署时,caliper测试时要指定参数--caliper-fabric-gateway-localhost false,否则默认都会将发现的节点终端转换成localhost。

    可以参考caliper官网文档的fabric-connector-settings的参数介绍
    https://hyperledger-caliper.github.io/caliper/0.6.0/concepts/runtime-config/?h=caliper+fabric+gateway+localhost#fabric-connector-settings

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

问题事件

  • 系统已结题 6月5日
  • 已采纳回答 5月28日
  • 创建了问题 5月28日