Failed to enroll admin in Hyperledger Fabric Javascript application - hyperledger-fabric

I followed instructions for writing my first app using Hyperledger Fabric, but when starting the app with node app.js I get this error:
$ node app.js
Loaded the network configuration located at C:\Users\marij\Desktop\hyper\fabric-
samples\test-network\organizations\peerOrganizations\org1.example.com\connection
-org1.json
Built a CA Client named ca-org1
Built a file system wallet at C:\Users\marij\Desktop\hyper\fabric-samples\asset-
transfer-basic\application-javascript\wallet
2021-06-03T18:30:33.180Z - error: [FabricCAClientService.js]: Failed to enroll a
dmin, error:%o message=Calling enroll endpoint failed with error [Error: connect
ECONNREFUSED 127.0.0.1:7054], stack=Error: Calling enroll endpoint failed with
error [Error: connect ECONNREFUSED 127.0.0.1:7054]
at ClientRequest.<anonymous> (C:\Users\marij\Desktop\hyper\fabric-samples\as
set-transfer-basic\application-javascript\node_modules\fabric-ca-client\lib\Fabr
icCAClient.js:327:19)
at ClientRequest.emit (events.js:315:20)
at TLSSocket.socketErrorListener (_http_client.js:469:9)
at TLSSocket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21), errno=
-4078, code=ECONNREFUSED, syscall=connect, address=127.0.0.1, port=7054
Failed to enroll admin user : Error: Calling enroll endpoint failed with error [
Error: connect ECONNREFUSED 127.0.0.1:7054]
An identity for the admin user does not exist in the wallet
Enroll the admin user before retrying
******** FAILED to run the application: Error: Identity not found in wallet: app
User
Wallet folder is empty.
Also, I didn't make any modifications in given code and I used test-network.

your wallet didn't have admin identity, you first need to enroll admin user and then try to register and enroll other user.

Related

Login failed while connecting to SQL Server database from Cube js

This is the issue I see in the terminal while i run
npm run dev
I am trying to connect to a SQL Server database. I have changed some settings for my user 'sjeswara' using SSMS which might facilitates connection:
Under securities -> Login I have set login as "enabled" for my user.
Under security of database property the setting "SQL Server and Window Authentication" property is also checked.
But this doesn't seem to solve the problem.
ConnectionError: Login failed for user 'sjeswara'.
at Connection. (D:\project\cube\testproj\node_modules\mssql\lib\tedious\connection-pool.js:68:17)
at Object.onceWrapper (events.js:422:26)
at Connection.emit (events.js:315:20)
at Connection.message (D:\project\cube\testproj\node_modules\tedious\lib\connection.js:2148:18)
at Connection.dispatchEvent (D:\project\cube\testproj\node_modules\tedious\lib\connection.js:1279:15)
at MessageIO. (D:\project\cube\testproj\node_modules\tedious\lib\connection.js:1139:14)
at MessageIO.emit (events.js:315:20)
at Message. (D:\project\cube\testproj\node_modules\tedious\lib\message-io.js:46:14)
at Message.emit (events.js:327:22)
at endReadableNT (D:\project\cube\testproj\node_modules\tedious\node_modules\readable-stream\lib_stream_readable.js:1094:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)

error after typing "node enrollAdmin.js" on windows

node enrollAdmin.js
error: [FabricCAClientService.js]: Failed to enroll admin, error:%o message=Calling enrollment endpoint failed with error [Error: con
nect ECONNREFUSED 127.0.0.1:7054], stack=Error: Calling enrollment endpoint fail
ed with error [Error: connect ECONNREFUSED 127.0.0.1:7054]
at ClientRequest.request.on (C:\Users\Nibir Hira\go\src\github.com\hyperledg
er\fabric-samples\fabcar\javascript\node_modules\fabric-ca-client\lib\FabricCACl
ient.js:487:12)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at Socket.socketErrorListener (_http_client.js:387:9)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
Failed to enroll admin user "admin": Error: Calling enrollment endpoint failed w
ith error [Error: connect ECONNREFUSED 127.0.0.1:7054]
Where should I do corrections? The file registeradmin.js is not even working
Here is a solution for Hyperledger Fabric v2.x. The problem is port no: 7054 is missing in test network.
In Linux (try if it works in virtual box), one way to solve is fresh restart from fabcar folder (not test network folder) then run again.
cd $HOME/fabric-samples/fabcar
./startFabric.sh javascript (by default it's goLang)
A fresh restart of the network will occur as "startFabric.sh" contains network up, down, chaincode installing, all in one.
Now try again:
node enrollAdmin.js
Worked for me.
Extra: Now you can run node registerUser.js and node invoke.js if you were about to use invoke.js .
Your node application cannot connect to the Fabric CA server running in the container - so either it is not running, has failed or possibly you have some firewall or other connectivity problem.
You can test connectivity by using wget or curl or a browser to hit this URL - http://localhost:7054/api/v1/cainfo and until you can hit this URL your enrollAdmin program will fail.
I don't use windows, but docker ps on Linux would tell me if the ca container was running, and docker logs ca.example.com would give me the log of the ca container (assuming you are running the fabcar sample on the basic sample network.)
I had the exact same problem. This worked for me:
Open VirtualBox Manager and select the “default” VM
Click “Settings”, “Network”, “Advanced”, “Port Forwarding”.
Create a new rule by clicking the “+” sign on the right and entering the following: Name -> “ca”, Host Port -> 7054, Guest Port -> 7054.
You can leave the Host IP and Guest IP unspecified.
Source:
https://developer.ibm.com/opentech/2017/11/29/running-hyperledger-fabric-windows-revised/

hyperledger fabric calling enrollment endpoint failed with error

I was trying to deploy hyperledger fabric on multiple hosts using this code and used the balance transfer chaincode using node-SDK. While I tried to enroll the user, I got the following error:
[2019-01-10 18:12:20.635] [ERROR] Helper -
[FabricCAClientService.js]: Failed to enroll admin, error:Error:
Calling enrollment endpoint failed with error [Error: write EPROTO
140678895621952:error:140770FC:SSL
routines:SSL23_GET_SERVER_HELLO:unknown
protocol:../deps/openssl/openssl/ssl/s23_clnt.c:827:
]
at ClientRequest.request.on (/home/muzzam/Downloads/hlf-docker-swarm/hlf-app/node_modules/fabric-ca-client/lib/FabricCAClient.js:492:12)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at TLSSocket.socketErrorListener (_http_client.js:387:9)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at onwriteError (_stream_writable.js:417:12)
at onwrite (_stream_writable.js:439:5)
at _destroy (internal/streams/destroy.js:39:7)
at TLSSocket.Socket._destroy (net.js:568:3)
can anyone give me an idea of what could be going wrong? If you need any of my configuration file, i can provide that
I was able to find my error.
I was not setting the TLS enabled parameter in docker containing CA service.
You need to set the following properties in yaml file containg the CA services:
environment:
- FABRIC_CA_SERVER_TLS_ENABLED=true
- FABRIC_CA_SERVER_TLS_CERTFILE=<location to certificate file>
- FABRIC_CA_SERVER_TLS_KEYFILE=<location to key file>

UnhandledPromiseRejectionWarning: error: password authentication failed for user " " after npm start

I am using node version 8 and when i do an npm start below errors are seen. I guess after routes are created below errors are seen. Here "techwedge3" is the username of my system. The application works correctly even with the below errors.
Even i am able to connect to my postgres db.
Any idea on how to resolve the issue?
[JobRoute::create] Creating route.
[InterviewRoute::create] Creating route.
[Creating AdminRoute::create] Creating route.
[TenantRoute::create] Creating route.
[CriteriaRoute::create] Creating route.
(node:12212) UnhandledPromiseRejectionWarning: error: password authentication failed for user "techwedge3"
at Connection.parseE (C:\Development\vilearnnew\vilearn_node\node_modules\pg-promise\node_modules\pg\lib\connection.js:546:11)
at Connection.parseMessage (C:\Development\vilearnnew\vilearn_node\node_modules\pg-promise\node_modules\pg\lib\connection.js:371:19)
at Socket.<anonymous> (C:\Development\vilearnnew\vilearn_node\node_modules\pg-promise\node_modules\pg\lib\connection.js:114:22)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)

Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED

I am trying to run the Hyperledger fabric Tuna app and getting the below error when running the regiseterAdmin.js
Store path:/home/chaindev/.hfc-key-store
Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 127.0.0.1:7054]
at ClientRequest.<anonymous> (/home/chaindev/fabricProjects/src/github.com/education/LFS171x/fabric-material/tuna-app/node_modules/fabric-ca-client/lib/FabricCAClientImpl.js:711:12)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at Socket.socketErrorListener (_http_client.js:387:9)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
Failed to enroll admin: Error: Failed to enroll admin
The issue was occurring for me because I had the wrong Private Key name mentioned in the docker-compose.yml file
FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/4239aa0dcd76daeeb8ba0cda701851d14504d31aad1b2ddddbac6a57365e497c_sk
When I re-generated the artificats the key file name was changed and after correction everything worked fine.
Also thanks for rocket-fabric group for mentioning the commands on how to look for logs in docker container. Below commands can be useful to debug
docker ps -a
docker logs <ca container name>
The docs need be updated on this. Localhost 127.0.0.1 does not work for Docker For Windows and Docker Toolbox as they both give their run-time IP address on start of Docker (here taken as 192.168.1.2).
This start-up IP needs to be updated in the registerAdmin.js file (or in my case enrollAdmin.js file as referred in the Tutorial "Writing First App" ).
The enrollAdmin.js needs be updated in this line:
// be sure to change the http to https when the CA is running TLS enabled
fabric_ca_client = new Fabric_CA_Client('http://192.168.1.2:7054', tlsOptions , 'ca.example.com', crypto_suite);
The output certificate should be like:
Successfully enrolled admin user "admin"
Assigned the admin user to the fabric client :: "name":"admin","mspid":"Org1MSP","roles":null,"affiliation":"","enrollmentSecret":"","enrollment": "signingIdentity":"c198861140fc723abc058c70d23395a2d7b73c926ca673b53d713053aaade419","identity":{"certificate":"-----BEGIN CERTIFICATE-----\nMIICATCCAaigAwIBAgIUK/o2ege+nT73jK/NXSgYIKoZIzj0EAwIw\nczELM...QnCkD6AiApKxxU1maQIt1TKFl3KYZWGBNDSSa6SCbob7q1p5xfpQ==\n-----END CERTIFICATE-----\n"}}}
Similar problem solved here.
As your .hfc-key-store directory is in chaindev,
Try running the following commands:
$ cd ~/chaindev/
$ rm -rf .hfc-key-store/
Then, run the command:
$ node registerAdmin.js
This can also happen if the port in PeerAdmin#Org.card does not match the port in docker-compose.yaml, I had hard time finding solution to this problem.
Mismatch in connection protocols, either you have done fabric setup without TLS and trying to connect to CA using https protocol or vice-versa.
Run docker ps and check if all the docker containers are running or not.
If it is not running run it, if it fail, download the fabric binaries.
I have the same error.
I run networkDown.sh and the run startFabric.sh again.Then it succeeded.

Resources