Reputation: 31
Under Hyperledger composer, I am trying to set up a persistent Rest Server using googleauth2.0 over a multi-org setup.
For the multi-org setup, I have followed https://hyperledger.github.io/composer/latest/tutorials/deploy-to-fabric-multi-org and for the google auth setup I have followed https://hyperledger.github.io/composer/latest/tutorials/google_oauth2_rest.
Everything goes fine until following step when I try to start a new instance of the extended Docker image for the REST server using following command
docker run
-d
-e COMPOSER_CARD=${COMPOSER_CARD}
-e COMPOSER_NAMESPACES=${COMPOSER_NAMESPACES}
-e COMPOSER_AUTHENTICATION=${COMPOSER_AUTHENTICATION}
-e COMPOSER_MULTIUSER=${COMPOSER_MULTIUSER}
-e COMPOSER_PROVIDERS="${COMPOSER_PROVIDERS}"
-e COMPOSER_DATASOURCES="${COMPOSER_DATASOURCES}"
-v ~/.composer:/home/composer/.composer
--name rest
--network composer_default
-p 3001:3001
org1/composer-rest-server
Following are the logs from rest container:
[2018-05-13 02:38:15] PM2 log: Launching in no daemon mode
[2018-05-13 02:38:16] PM2 log: Starting execution sequence in -fork mode- for app name:composer-rest-server id:0
[2018-05-13 02:38:16] PM2 log: App name:composer-rest-server id:0 online
WARNING: NODE_APP_INSTANCE value of '0' did not match any instance config file names.
WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
Discovering types from business network definition ...
Connection fails: Error: Error trying to ping. Error: No peers available to query. last error was Error: 14 UNAVAILABLE: Connect Failed
It will be retried for the next request.
Exception: Error: Error trying to ping. Error: No peers available to query. last error was Error: 14 UNAVAILABLE: Connect Failed
Error: Error trying to ping. Error: No peers available to query. last error was Error: 14 UNAVAILABLE: Connect Failed
at _checkRuntimeVersions.then.catch (/home/composer/.npm-global/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:790:34)
at <anonymous>
[2018-05-13 02:38:29] PM2 log: App [composer-rest-server] with id [0] and pid [14], exited with code [1] via signal [SIGINT]
Here are the docker containers:
233938f12ef0 org1/composer-rest-server "pm2-docker composer…" 30 minutes ago Up 30 minutes 3000/tcp, 0.0.0.0:3001->3001/tcp rest
6285853fdceb dev-peer1.org1.example.com-emcs-0.0.3-b1bb3a7f1090c0d1cabf10340188aa72e329e1266595f63d232d9cc38a0ed8b8 "/bin/sh -c 'cd /usr…" About an hour ago Up About an hour dev-peer1.org1.example.com-emcs-0.0.3
1a4f7680cac9 dev-peer0.org1.example.com-emcs-0.0.3-094e3600469176994df7048ec5afad4114ce5203fe267b0c45da52a3d3b9e0b7 "/bin/sh -c 'cd /usr…" About an hour ago Up About an hour dev-peer0.org1.example.com-emcs-0.0.3
b7c7364c88bd dev-peer0.org2.example.com-emcs-0.0.3-3f76658cf8352417e15be589ed41aa0fa81e702a1bdb6e7e1ce898a015fdd34c "/bin/sh -c 'cd /usr…" About an hour ago Up About an hour dev-peer0.org2.example.com-emcs-0.0.3
b154cd4f50bd dev-peer1.org2.example.com-emcs-0.0.3-340eb1dbb0152185d068724d637848c882bd3754f7c9888d57c80bdfb6530774 "/bin/sh -c 'cd /usr…" About an hour ago Up About an hour dev-peer1.org2.example.com-emcs-0.0.3
f9d2a72fde40 dev-peer1.org2.example.com-mycc-1.0-26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d01f8346ab "chaincode -peer.add…" 2 hours ago Up 2 hours dev-peer1.org2.example.com-mycc-1.0
d812bef3a1bd dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9 "chaincode -peer.add…" 2 hours ago Up 2 hours dev-peer0.org1.example.com-mycc-1.0
ccb70e752d7b dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b "chaincode -peer.add…" 2 hours ago Up 2 hours dev-peer0.org2.example.com-mycc-1.0
6989f8850296 hyperledger/fabric-tools "/bin/bash -c './scr…" 2 hours ago Up 2 hours cli
0eabbd6be684 hyperledger/fabric-peer "peer node start" 2 hours ago Up 2 hours 0.0.0.0:10051->7051/tcp, 0.0.0.0:10053->7053/tcp peer1.org2.example.com
d8c1146a5989 hyperledger/fabric-peer "peer node start" 2 hours ago Up 2 hours 0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp peer1.org1.example.com
142aeb4525ab hyperledger/fabric-peer "peer node start" 2 hours ago Up 2 hours 0.0.0.0:9051->7051/tcp, 0.0.0.0:9053->7053/tcp peer0.org2.example.com
70ef571ea1ba hyperledger/fabric-peer "peer node start" 2 hours ago Up 2 hours 0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp peer0.org1.example.com
31c8417beae2 hyperledger/fabric-ca "sh -c 'fabric-ca-se…" 2 hours ago Up 2 hours 0.0.0.0:8054->7054/tcp ca_peerOrg2
ade3061fc517 hyperledger/fabric-orderer "orderer" 2 hours ago Up 2 hours 0.0.0.0:7050->7050/tcp orderer.example.com
e315be1721d9 hyperledger/fabric-couchdb "tini -- /docker-ent…" 2 hours ago Up 2 hours 4369/tcp, 9100/tcp, 0.0.0.0:8984->5984/tcp couchdb3
0197051ffaf6 hyperledger/fabric-couchdb "tini -- /docker-ent…" 2 hours ago Up 2 hours 4369/tcp, 9100/tcp, 0.0.0.0:6984->5984/tcp couchdb1
5abd60481ec3 hyperledger/fabric-couchdb "tini -- /docker-ent…" 2 hours ago Up 2 hours 4369/tcp, 9100/tcp, 0.0.0.0:7984->5984/tcp couchdb2
58205a7b26fe hyperledger/fabric-ca "sh -c 'fabric-ca-se…" 2 hours ago Up 2 hours 0.0.0.0:7054->7054/tcp ca_peerOrg1
13009c1401fb hyperledger/fabric-couchdb "tini -- /docker-ent…" 2 hours ago Up 2 hours 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp couchdb0
1ef9ab29b607 mongo "docker-entrypoint.s…" 2 hours ago Up 2 hours 0.0.0.0:27017->27017/tcp mongo
I have already gone through some errors which have been received by others, and so have already performed following additional steps:
I have tried cleaning up all my docker containers and images, stopping the fabric and starting the fabric but it still comes up with the same error..
Expected behaviour is that the command docker logs -f rest should finish with Browse your REST API at http://localhost:3001/explorer. However, it results in the above error.
Upvotes: 3
Views: 1914
Reputation: 41
Try replacing your peer0.org1.example.com
, peer0.org1.example.com
, ca.org1.example.com
and orderer.example.com
in
sed -e 's/localhost:7051/peer0.org1.example.com:7051/' \
-e 's/localhost:7053/peer0.org1.example.com:7053/' \
-e 's/localhost:7054/ca.org1.example.com:7054/' \
-e 's/localhost:7050/orderer.example.com:7050/' \
< $HOME/.composer/cards/restadmin@trade-network/connection.json \
> /tmp/connection.json && \
cp -p /tmp/connection.json $HOME/.composer/cards/restadmin@trade-network/
command with your ip adddress like :
sed -e 's/localhost:7051/192.168.0.170:7051/' \
-e 's/localhost:7053/192.168.0.170:7053/' \
-e 's/localhost:7054/192.168.0.170:7054/' \
-e 's/localhost:7050/192.168.0.170:7050/' \
< $HOME/.composer/cards/restadmin@trade-network/connection.json \
> /tmp/connection.json && \
cp -p /tmp/connection.json $HOME/.composer/cards/restadmin@trade-network/
Upvotes: 2
Reputation: 5868
The Google Auth tutorial isn't expecting a fabric set up from the multiorg tutorial so isn't going to work if you follow the steps. The Auth tutorial is designed to work with the single org provided by the development fabric from setting up the composer development environment or running the single org tutorial. The problem will be that the connection.json needs to describe the multi-org setup (so you will need an appropriate connection profile from the multi-org tutorial) and as you are running your rest server in a docker container and are attaching to the network which all the hyperledger fabric containers are connected to you cannot use hostnames and addresses such as localhost
, 127.0.0.1
or 0.0.0.0
to try to address the different hyperledger fabric processes (all of these will actually refer to your rest server container). You need to use the correct hostnames to identify them. For example
orderer.example.com for the orderer
peer0.org1.example.com for peer0.org1.example.com (and similar for the other peers)
ca0 for the certificate authority in org1, ca1 for the certificate authority in org2
Upvotes: 2