Hyperledger Fabric v2.1:Fabcar,在网关连接选项中将asLocalhost设置为false

如何解决Hyperledger Fabric v2.1:Fabcar,在网关连接选项中将asLocalhost设置为false

我正在尝试运行Hyperledger Fabric的多计算机网络。我遇到了一些错误。通过在fabric-samples/fabcar/javascript/query.js中更改一行,我能够在Fabric v2.1的Fabcar example中的同一台计算机上重现相同的错误。我换了线

await gateway.connect(ccp,{ wallet,identity: 'appUser',discovery: { enabled: true,asLocalhost: true } });

一行

await gateway.connect(ccp,asLocalhost: false } });

因此,我将discovery.asLocalhost设置为false而不是true。当我在node query.js目录中运行fabric-samples/fabcar/javascript/时。我收到以下错误。

Wallet path: /home/userName/my/code/fabric-samples/fabcar/javascript/wallet
2020-10-23T06:09:56.505Z - error: [ServiceEndpoint]: Error: Failed to connect before the deadline on Committer- name: orderer.example.com:7050,url:grpcs://orderer.example.com:7050
2020-10-23T06:09:56.507Z - error: [ServiceEndpoint]: waitForReady - Failed to connect to remote gRPC server orderer.example.com:7050 url:grpcs://orderer.example.com:7050 timeout:3000
2020-10-23T06:09:56.508Z - error: [DiscoveryService]: _buildOrderer[mychannel] - Unable to connect to the discovered orderer orderer.example.com:7050 due to Error: Failed to connect before the deadline on Committer- name: orderer.example.com:7050,url:grpcs://orderer.example.com:7050
2020-10-23T06:09:59.522Z - error: [ServiceEndpoint]: Error: Failed to connect before the deadline on Endorser- name: peer0.org1.example.com:7051,url:grpcs://peer0.org1.example.com:7051
2020-10-23T06:09:59.523Z - error: [ServiceEndpoint]: waitForReady - Failed to connect to remote gRPC server peer0.org1.example.com:7051 url:grpcs://peer0.org1.example.com:7051 timeout:3000
2020-10-23T06:09:59.523Z - error: [DiscoveryService]: _buildPeer[mychannel] - Unable to connect to the discovered peer peer0.org1.example.com:7051 due to Error: Failed to connect before the deadline on Endorser- name: peer0.org1.example.com:7051,url:grpcs://peer0.org1.example.com:7051
2020-10-23T06:10:02.528Z - error: [ServiceEndpoint]: Error: Failed to connect before the deadline on Endorser- name: peer0.org2.example.com:9051,url:grpcs://peer0.org2.example.com:9051
2020-10-23T06:10:02.528Z - error: [ServiceEndpoint]: waitForReady - Failed to connect to remote gRPC server peer0.org2.example.com:9051 url:grpcs://peer0.org2.example.com:9051 timeout:3000
2020-10-23T06:10:02.529Z - error: [DiscoveryService]: _buildPeer[mychannel] - Unable to connect to the discovered peer peer0.org2.example.com:9051 due to Error: Failed to connect before the deadline on Endorser- name: peer0.org2.example.com:9051,url:grpcs://peer0.org2.example.com:9051
2020-10-23T06:10:02.564Z - error: [SingleQueryHandler]: evaluate: message=Query failed. Errors: [],stack=FabricError: Query failed. Errors: []
    at SingleQueryHandler.evaluate (/home/sarva/my/code/viacomrepos/temp-fabric-samples/fabric-samples/fabcar/javascript/node_modules/fabric-network/lib/impl/query/singlequeryhandler.js:45:23)
    at Transaction.evaluate (/home/sarva/my/code/viacomrepos/temp-fabric-samples/fabric-samples/fabcar/javascript/node_modules/fabric-network/lib/transaction.js:287:49)
    at Contract.evaluateTransaction (/home/sarva/my/code/viacomrepos/temp-fabric-samples/fabric-samples/fabcar/javascript/node_modules/fabric-network/lib/contract.js:115:45)
    at main (/home/sarva/my/code/viacomrepos/temp-fabric-samples/fabric-samples/fabcar/javascript/query.js:46:39)
    at processTicksAndRejections (internal/process/task_queues.js:85:5),name=FabricError
Failed to evaluate transaction: FabricError: Query failed. Errors: []

我遵循了Fabcar tutorial中的说明。下面是重现该错误的步骤。

cd fabric-samples/fabcar
./startFabric.sh javascript
cd javascript
npm install
node enrollAdmin.js
node registerUser.js
[Change the line in query.js]
node query.js

如果我能弄清楚如何/在哪里指定grpcs URL,我认为我可以使多机网络正常工作。任何帮助表示赞赏。

可以按照this answer的建议设置export GRPC_TRACE=allexport GRPC_VERBOSITY=DEBUG来获取更详细的错误日志。

解决方法

在单机情况下,客户端应用程序在本地计算机上运行,​​但是节点(对等节点和订购者)在本地计算机上的Docker容器中运行,并且主机名类似peer0.org1.example.com

在Docker网络中,节点可以使用其主机名相互通信,例如peer0.org1.example.com。您的客户端(在Docker网络外部)无法与peer0.org1.example.com进行对话,因为该DNS名称不存在。相反,它需要通过Docker网络映射到Docker网络中特定主机/端口或从Docker网络映射到特定主机/端口的端口上的localhost。

您的客户端应用程序通过两种方式获取节点端点:

  1. 其本地连接配置文件中的条目。
  2. 服务发现返回的网络拓扑。

您可以在连接配置文件中设置适当的(本地主机)端点URL。但是,发现返回的端点URL将是Docker网络中公开的那些URL。 peer0.org1.example.com。为了简化这种情况,SDK提供了discovery.asLocalhost设置,该设置启用后会将发现返回的所有终结点地址映射到localhost的同一端口。一种替代方法是将条目添加到本地主机文件中,这些条目将节点名称映射到localhost。

如果您的节点可以使用其配置的主机名在实际网络上访问,则不应启用discovery.asLocalhost设置。这些主机名在DNS中必须是可解析的(因此对于实际部署,您不能使用诸如example.com之类的不可解析的地址),并且必须与您的Fabric网络配置(以及使用TLS的服务器证书详细信息)相匹配。

,

用于设置多机器网络。您必须进行的更改是在config.json和connection.yaml(基本上是连接配置文件)上。

await gateway.connect(ccp,{ wallet,identity: 'appUser',discovery: { enabled: true,asLocalhost: false } });

在设置多主机区块链网络时,应将localhost属性设置为“ false”。您可以创建一个覆盖网络以与其连接。

    ---
  name: mychannel.firstnetwork.connectionprofile
  x-type: "hlfv1"
  description: "connection profile for 2.1  network"
  version: "1.0"
  
  channels:
    mychannel:
      orderers:
        - orderer.example.com
      peers:
        peer0.org1.example.com:
          endorsingPeer: true
          chaincodeQuery: true
          ledgerQuery: true
          eventSource: true
        peer0.org2.example.com:
          endorsingPeer: true
          chaincodeQuery: true
          ledgerQuery: true
          eventSource: true
  
  organizations:
    Org1:
      mspid: Org1MSP
      peers:
        - peer0.org1.example.com
      certificateAuthorities:
        - ca.org1.example.com
      adminPrivateKey:
        path:  ./caro-blockchain-commonfiles/config/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/8717c2e82c3c4caff76fca964bb70_sk
      signedCert:
        path:  ./caro-blockchain-commonfiles/config/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/cert.pem
    
    Org2:
      mspid: Org2MSP
      peers:
        - peer0.org2.example.com
      certificateAuthorities:
        - ca.org2.example.com
      adminPrivateKey:
        path:  ./caro-blockchain-commonfiles/config/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/keystore/9592495c719c2e87fc4a8_sk
      signedCert:
        path:  ./caro-blockchain-commonfiles/config/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts/cert.pem
  orderers:
    orderer.example.com:
      url: grpcs://orderer.example.com:7050
      grpcOptions:
       ssl-target-name-override: orderer.example.com
      tlsCACerts:
        path:  ./caro-blockchain-commonfiles/config/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
  
  peers:
    peer0.org1.example.com:
      url: grpcs://peer0.org1.example.com:7051
      grpcOptions:
        ssl-target-name-override: peer0.org1.example.com
      tlsCACerts:
        path: ./caro-blockchain-commonfiles/config/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/cacerts/localhost-7054-ca-org1.pem
  
   
    peer0.org2.example.com:
      url: grpcs://peer0.org2.example.com:9051
      grpcOptions:
        ssl-target-name-override: peer0.org2.example.com
      tlsCACerts:
        path: ./caro-blockchain-commonfiles/config/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/cacerts/localhost-8054-ca-org2.pem
  
   
  
  certificateAuthorities:
    ca.org1.example.com:
      url: https://ca.org1.example.com:7054
      httpOptions:
        verify: false
      tlsCACerts:
        path: ./caro-blockchain-commonfiles/config/crypto-config/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem
      registrar:
        - enrollId: admin
          enrollSecret: adminpw
      caName: ca-org1
    ca.org2.example.com:
      url: https://ca.org2.example.com:8054
      httpOptions:
        verify: false
      tlsCACerts:
        path: ./caro-blockchain-commonfiles/config/crypto-config/peerOrganizations/org2.example.com/ca/ca.org2.example.com-cert.pem
      registrar:
        - enrollId: admin
          enrollSecret: adminpw
      caName: ca-org2

此处的grpcs://peer0.org1.example.com:7051这样的URLs属性应从主机名更改为另一台计算机的IP,再更改为运行对等容器的VM(grpcs://XX.XX.XX.XX:7051)。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 <select id="xxx"> SELECT di.id, di.name, di.work_type, di.updated... <where> <if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 <property name="dynamic.classpath" value="tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-