1

I have a chaincode installed and running over EC2 instance, which was accomplished using an AWS managed blockchain.

Fabric client side:

I kept the EC2 instance acting as the fabric client side. It has a connection profile, package.json, app.js. I created two javascript files, which were used to register and enroll admin, and then user1. The certificates were stored inside a wallet in the EC2 instance.

I was able to accomplish API calling by running the app.js file that contains API methods for the chaincode running over the EC2 instance.

Here is the docker compose file which was taken from aws-samples repo:

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 Server:

I am currently trying to call the API from my local machine by making it as the Fabric API server.

The things I did so far is as follows:

1) I have copied the package.json, connection.yaml, wallet/User1 to the local machine

2) I have modified the connection profile with respect to Fabric API server using

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

Here is the connection.yaml file

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) Added entries in /etc/hosts such that they will point to Fabric Client. {I feel I might be wrong with this configurations}

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

Here is an example of how I gave the IP for peer1 and orderer.com in the entries.

eg; 18.18.111.252 peer1

Once everything has been set up, I ran the app.js which ran at port 3000. While testing the api here using the local machine, I found few errors regarding DNS resolution.

{"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>"}}

I wonder where might be the issues over the configurations I attempted. Kindly advice. Thanks.

Aldo
  • 158
  • 1
  • 10

0 Answers0