使用AWS托管区块链为Hyperledger Fabric Network实现API Server时,DNS解析失败?

我安装并运行了EC2实例上的链码,这是使用AWS管理的区块链完成的。

面料客户端:

我让EC2实例充当结构客户端。它具有连接配置文件package.json,app.js。我创建了两个JavaScript文件,分别用于注册和注册admin,然后是user1。证书存储在EC2实例的钱包中。

通过运行包含在EC2实例上运行的链码的API方法的app.js文件,我能够完成API调用。

这是从aws-samples存储库中提取的docker compose文件:

version: '2'
services:
  cli:
    container_name: cli
    image: hyperledger/fabric-tools:1.2.0
    tty: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_LOGGING_LEVEL=info # Set logging level to debug for more verbose logging
      - CORE_PEER_ID=cli
      - CORE_CHAINCODE_KEEPALIVE=10
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
        - /var/run/:/host/var/run/
        - /home/ec2-user/fabric-samples/chaincode:/opt/gopath/src/github.com/
        - /home/ec2-user:/opt/home

Fabric API服务器:

我目前正试图通过将其作为Fabric API服务器从本地计算机上调用API。

到目前为止,我所做的事情如下:

1)我已将package.json,connection.yaml,wallet / User1复制到本地计算机

2)我已经使用以下方法修改了与Fabric API服务器有关的连接配置文件

sed -i 's/localhost/[Fabric-Client-IP]/g' connection.yaml

这是connection.yaml文件

name: "Test"
x-type: "hlfv1"
description: "My Network"
version: "1.0"

channels:
  mychannel:
    orderers:
      - orderer.com
    peers:
      peer1:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true

organizations:
  Org1:
    mspid: %MEMBERID%
    peers:
      - peer1
    certificateAuthorities:
      - ca-org1

orderers:
  orderer.com:
    url: grpcs://%ORDERINGSERVICEENDPOINT%
    grpcOptions:
      ssl-target-name-override: %ORDERINGSERVICEENDPOINTNOPORT%
    tlsCACerts:
      path: %CAFILE%

peers:
  peer1:
    url: grpcs://%PEERSERVICEENDPOINT%
    eventUrl: grpcs://%PEEREVENTENDPOINT%
    grpcOptions:
      ssl-target-name-override: %PEERSERVICEENDPOINTNOPORT%
    tlsCACerts:
      path: %CAFILE%

certificateAuthorities:
  ca-org1:
    url: https://%CASERVICEENDPOINT%
    httpOptions:
      verify: false
    tlsCACerts:
      path: %CAFILE%
    registrar:
      - enrollId: %ADMINUSER%
        enrollSecret: %ADMINPWD%
    caName: %MEMBERID%

3)在/ etc / hosts中添加了条目,以便它们将指向Fabric Client。 {我觉得这个配置可能不对}

127.0.0.1 localhost
[Fabric-Client side-IP] orderer.com
[Fabric-Client side-IP] peer1

这是我如何在条目中为peer1和orderer.com提供IP的示例。

eg; 18.18.111.252 peer1

设置完所有内容后,我运行了在端口3000上运行的app.js。使用本地计算机在此处测试api时,我发现几乎没有与DNS解析有关的错误。

{"error":{"message":"Unable to initialize channel. Attempted to contact 1 Peers. Last error was Error: 14 UNAVAILABLE: DNS resolution failed","stack":"Error: Unable to initialize channel. Attempted to contact 1 Peers. Last error was Error: 14 UNAVAILABLE: DNS resolution failed\n    at Network._initializeInternalChannel (/home/Desktop/app/node_modules/fabric-network/lib/network.js:119:12)\n    at <anonymous>"}}

我不知道我尝试的配置可能出什么问题。 好心劝告。 谢谢。