问题
Following: https://hyperledger.github.io/composer/v0.19/tutorials/google_oauth2_rest
I have the same problem of:
Hyperledger Composer multi-user mode: ECONNREFUSED for issued identities
Basically, i have two rest server and when i issue a id from port 3001 (admin card single user) then import and try to ping on port 3000 (multi-user), the same error appears. Seems like the card are being imported with the wrong hostname.
But i can't do the same that the user says: " I changed the URLs over there instead of modifying the cards after creating them. This has solved the issue as now the cards are generated with proper container URLs rather than localhost. "
When i do
composer identity issue -c admin@amachains -f restadmin.card -u restadmin -a "resource:org.hyperledger.composer.system.NetworkAdmin#restadmin"
composer card import -f restadmin.card
composer network ping -c restadmin@amachains
cd ..
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@amachains/connection.json > /tmp/connection.json && cp -p /tmp/connection.json $HOME/.composer/cards/restadmin@amachains/
and then export this and import in 3000 rest server, the ping works.
That is my script for start my whole project:
# !/bin/bash
sudo kill $(sudo lsof -t -i:3000)
sudo kill $(sudo lsof -t -i:3001)
sudo kill $(sudo lsof -t -i:4200)
# Stop Fabric & Teardown Fabric
~/fabric-dev-servers/stopFabric.sh && ~/fabric-dev-servers/teardownFabric.sh
# Clean Composer
rm -rf ~/.composer
# Clean Docker containers
docker kill $(docker ps -q)
docker rm $(docker ps -aq)
# Clean Docker images
docker rmi $(docker images dev-* -q)
# Clean Docker images
docker rmi $(docker images amachains/* -q)
# Start Fabric & Create Peer Admin Card
~/fabric-dev-servers/startFabric.sh && ~/fabric-dev-servers/createPeerAdminCard.sh
docker run -d --name mongo --network composer_default -p 27017:27017 mongo
cd dockertmp
docker build -t amachains/amachains-rest-server .
cd ..
# Install BNA on Hyperledger Faric with Hyperledger Composer
cd ./amachains-bna
composer archive create -t dir -n .
composer network install --card PeerAdmin@hlfv1 --archiveFile amachains@0.0.1.bna
composer network start --networkName amachains --networkVersion 0.0.1 --networkAdmin admin --networkAdminEnrollSecret adminpw --card PeerAdmin@hlfv1 --file networkadmin.card
composer card import --file networkadmin.card
composer network ping -c admin@amachains
composer participant add -c admin@amachains -d '{"$class":"org.hyperledger.composer.system.NetworkAdmin", "participantId":"restadmin"}'
composer identity issue -c admin@amachains -f restadmin.card -u restadmin -a "resource:org.hyperledger.composer.system.NetworkAdmin#restadmin"
composer card import -f restadmin.card
composer network ping -c restadmin@amachains
cd ..
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@amachains/connection.json > /tmp/connection.json && cp -p /tmp/connection.json $HOME/.composer/cards/restadmin@amachains/
source envvars.txt
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 3000:3000 \
amachains/amachains-rest-server
# docker ps |grep rest
# docker logs -f rest
cd amachains-client/
composer-rest-server -c admin@amachains -p 3001 & npm start
system/ping on rest server port 3000 should be ok status but i get:
ERROR Error: Uncaught (in promise): HttpErrorResponse: {"headers":{"normalizedNames":{},"lazyUpdate":null},"status":500,"statusText":"Internal Server Error","url":"http://localhost:3000/api/system/ping","ok":false,"name":"HttpErrorResponse","message":"Http failure response for http://localhost:3000/api/system/ping: 500 Internal Server Error","error":{"error":{"statusCode":500,"name":"Error","message":"Error trying login and get user Context. Error: Error trying to enroll user. Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 127.0.0.1:7054]","stack":"Error: Error trying login and get user Context. Error: Error trying to enroll user. Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 127.0.0.1:7054]\n at HLFConnection.login (/home/composer/.npm-global/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:477:30)\n at <anonymous>\n at process._tickCallback (internal/process/next_tick.js:189:7)"}}}
来源:https://stackoverflow.com/questions/57187913/hyperledger-composer-ping-on-rest-multi-user-mode-econnrefused-for-issued-ident