Docker: How to connect Node.js in container to Hyperledger Fabric?

0 votes

Dockerfile:

FROM node:carbon

WORKDIR /usr/src/app

COPY package*.json ./

COPY *.card ./

RUN npm install

RUN ./node_modules/.bin/composer card import --file admin@samplenetwork.card --card admin@samplenetwork

COPY . .

EXPOSE 8080

CMD [ "npm", "start" ]

connection.js used to create admin@samplenetwork.card (I replaced "://localhost:port" with the running container names) 

{ 

    "name":"hlfv1",

    "x-type":"hlfv1",

    "x-commitTimeout":300,

    "version":"1.0.0",

    "client":{ 

       "organization":"Org1",

       "connection":{ 

          "timeout":{ 

             "peer":{ 

                "endorser":"300",

                "eventHub":"300",

                "eventReg":"300"

             },

             "orderer":"300"

          }

       }

    },

    "channels":{ 

       "composerchannel":{ 

          "orderers":[ 

             "orderer.example.com"

          ],

          "peers":{ 

             "peer0.org1.example.com":{ 


             }

          }

       }

    },

    "organizations":{ 

       "Org1":{ 

          "mspid":"Org1MSP",

          "peers":[ 

             "peer0.org1.example.com"

          ],

          "certificateAuthorities":[ 

             "ca.org1.example.com"

          ]

       }

    },

    "orderers":{ 

       "orderer.example.com":{ 

          "url":"grpc://orderer.example.com:7050"

       }

    },

    "peers":{ 

       "peer0.org1.example.com":{ 

          "url":"grpc://peer0.org1.example.com:7051",

          "eventUrl":"grpc://peer0.org1.example.com:7053"

       }

    },

    "certificateAuthorities":{ 

       "ca.org1.example.com":{ 

          "url":"http://ca.org1.example.com:7054",

          "caName":"ca.org1.example.com"

       }

    }

 }

Node.js app cannot connect:

(node:17) UnhandledPromiseRejectionWarning: Error: Error trying to ping. Error: 2 UNKNOWN: error executing chaincode: transaction returned with failure: Error: The current identity, with the name 'admin' and the identifier 'fcb2071b5df74a16b4b93b14bff69af15c1104df6465a23ae4ec3473cc663d71', has not been registered

Can someone tell me how to do this?

Oct 31, 2018 in Blockchain by slayer
• 29,040 points
62 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

You need to map ~/.composer/cards of your Docker host to ~/.composer/cards of your container. And then you will be able to connect it.

answered Oct 31, 2018 by Omkar
• 66,880 points

Related Questions In Blockchain

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
3 answers
0 votes
1 answer
+2 votes
3 answers
0 votes
1 answer

How to connect channels of different systems in Hyperledger Fabric?

When you create a channel, you will ...READ MORE

answered Nov 20, 2018 in Blockchain by Omkar
• 66,880 points
52 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.