运行Hyperledger Fabric Gateway时DNS解析器提供了错误的IP地址

问题描述

我正在运行一个JS文件,该文件充当Hyperledger Fabric网络上一组通道的侦听器。尽管我描述了以下错误,但侦听器仍能够基于控制台输出中的证据来侦听该频道(这使我感到困惑)(下面提供了摘录)。在此代码投入生产时,即使功能不受影响,我也需要解决所有错误

所以我对以下JavaScript代码摘录有疑问:

let network,listener;
for (var i = 0; i < channelid.length; i++) {
  let cid = channelid[i];
  console.log(`Adding listener for channel ${cid}`);
  network = await gateway.getNetwork(cid);
  console.log(`await gateway.getNetwork`);
  listener = await network.addBlockListener(
    async (event) => {
      await ProcessingMap.set(event.blockData.header.number,event.blockData);
      console.log(
        `Added block ${event.blockData.header.number} to ProcessingMap`,);
    },{startBlock: parseInt(nextBlock,10)},);
  console.log(`await network.addBlockListener`);
}

(完整代码可在https://pastebin.com/qqFPdVH6上找到)

当我使用export GRPC_VERBOSITY=DEBUGexport GRPC_TRACE=all运行此代码时,在行network = await gateway.getNetwork(cid)处收到以下错误(可以在以下位置找到有关开始读取块的完整日志: https://pastebin.com/ZxJBx4ub


2020-10-06T07:43:24.424Z | resolving_load_balancer | dns:orderer1.isprint.com:7050 IDLE -> IDLE
2020-10-06T07:43:24.424Z | connectivity_state | dns:orderer1.isprint.com:7050 IDLE -> IDLE
2020-10-06T07:43:24.424Z | dns_resolver | Resolver constructed for target dns:orderer1.isprint.com:7050
2020-10-06T07:43:24.425Z | dns_resolver | Resolution update requested for target dns:orderer1.isprint.com:7050
2020-10-06T07:43:24.425Z | resolving_load_balancer | dns:orderer1.isprint.com:7050 IDLE -> CONNECTING
2020-10-06T07:43:24.425Z | connectivity_state | dns:orderer1.isprint.com:7050 IDLE -> CONNECTING
2020-10-06T07:43:24.426Z | resolving_load_balancer | dns:orderer1.isprint.com:7050 CONNECTING -> CONNECTING
2020-10-06T07:43:24.426Z | connectivity_state | dns:orderer1.isprint.com:7050 CONNECTING -> CONNECTING
2020-10-06T07:43:24.427Z | dns_resolver | Resolved addresses for target dns:orderer1.isprint.com:7050: [35.186.238.101:7050]
2020-10-06T07:43:24.427Z | pick_first | IDLE -> IDLE
2020-10-06T07:43:24.427Z | resolving_load_balancer | dns:orderer1.isprint.com:7050 CONNECTING -> IDLE
2020-10-06T07:43:24.427Z | connectivity_state | dns:orderer1.isprint.com:7050 CONNECTING -> IDLE
2020-10-06T07:43:24.427Z | pick_first | Connect to address list 35.186.238.101:7050
2020-10-06T07:43:24.427Z | subchannel | 35.186.238.101:7050 refcount 0 -> 1
2020-10-06T07:43:24.427Z | subchannel | 35.186.238.101:7050 refcount 1 -> 2
2020-10-06T07:43:24.427Z | pick_first | Start connecting to subchannel with address 35.186.238.101:7050
2020-10-06T07:43:24.427Z | pick_first | IDLE -> CONNECTING
2020-10-06T07:43:24.427Z | resolving_load_balancer | dns:orderer1.isprint.com:7050 IDLE -> CONNECTING
2020-10-06T07:43:24.427Z | connectivity_state | dns:orderer1.isprint.com:7050 IDLE -> CONNECTING
2020-10-06T07:43:24.427Z | subchannel | 35.186.238.101:7050 IDLE -> CONNECTING
2020-10-06T07:43:24.427Z | pick_first | CONNECTING -> CONNECTING
2020-10-06T07:43:24.427Z | resolving_load_balancer | dns:orderer1.isprint.com:7050 CONNECTING -> CONNECTING
2020-10-06T07:43:24.427Z | connectivity_state | dns:orderer1.isprint.com:7050 CONNECTING -> CONNECTING
2020-10-06T07:43:27.428Z - error: [ServiceEndpoint]: Error: Failed to connect before the deadline on Committer- name: orderer1.isprint.com:7050,url:grpcs://orderer1.isprint.com:7050,connected:false,connectAttempted:true
2020-10-06T07:43:27.429Z - error: [ServiceEndpoint]: waitForReady - Failed to connect to remote gRPC server orderer1.isprint.com:7050 url:grpcs://orderer1.isprint.com:7050 timeout:3000
2020-10-06T07:43:27.429Z - error: [discoveryService]: _buildOrderer[isprintchannel] - Unable to connect to the discovered orderer orderer1.isprint.com:7050 due to Error: Failed to connect before the deadline on Committer- name: orderer1.isprint.com:7050,connectAttempted:true

我不知道DNS解析器为什么给我奇怪的IP地址35.186.238.101,所以我做了nslookup 35.186.238.101

[root@isprintdev nodejs]# nslookup 35.186.238.101
Server:         192.168.1.8
Address:        192.168.1.8#53

Non-authoritative answer:
101.238.186.35.in-addr.arpa     name = 101.238.186.35.bc.googleusercontent.com.
Authoritative answers can be found from:

[root@isprintdev nodejs]#

可以在https://pastebin.com/Ppe9JPXR上找到连接配置文件。简而言之,我的网络由三个订购者和两个对等点组成,它们都在同一虚拟机上。

所以我的问题是:我需要在连接配置文件或JS代码中(或在任何必要的地方)更改某些内容,以确保不会出现此错误吗?

解决方法

playerJumps(Jumper j)具有公共DNS条目,并且显然具有通配符DNS A记录,可将playerRuns(Runner r)解析为isprint.com

*.isprint.com

不确定您如何运行Fabric(Docker,二进制文件等),也不确定您如何运行客户端,但是您的JS应用看起来很可能直接在主机VM上运行,因此正在使用配置的DNS分辨率,如上解决。假设您的Fabric节点通过Docker / Docker Compose运行,则可以使用35.186.238.101来摆脱它们,因为它们将在外部DNS解析之前在Docker网络上进行解析。

因此,要保存您的问题,您需要创建一个HOSTS文件条目,该条目将您的端点映射到客户端可用于访问Fabric节点的VM内的IP。

在* nix系统上,您需要编辑MacBook-Pro:~ garis$ nslookup orderer1.isprint.com Server: 192.168.1.1 Address: 192.168.1.1#53 Non-authoritative answer: Name: orderer1.isprint.com Address: 35.186.238.101 并添加如下条目:

isprint.com