Audrius Meškauskas
Audrius Meškauskas

Reputation: 21778

query.js crash on Hyperledger fabric fabcar example

The fabcar example of the hyperledger tutorial crashes for me at the step of attempting to run query.js.

I have removed all hyperledger related docker images (with docker rmi), so all required content was downloaded automatically when running startFabric.sh. The output on startup looks slightly "clouded" but not very suspicious (I skipped the lengthy output about the images being downloaded):

# wait for Hyperledger Fabric to start
# incase of errors when running later commands, issue export FABRIC_START_TIMEOUT=<larger number>
export FABRIC_START_TIMEOUT=10
#echo ${FABRIC_START_TIMEOUT}
sleep ${FABRIC_START_TIMEOUT}

# Create the channel
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c mychannel -f /etc/hyperledger/configtx/channel.tx
flag provided but not defined: -e
See 'docker exec --help'.

The next step as asked is

npm install

It also delivers mostly ok output,just one warning:

npm WARN [email protected] No repository field.

I have verified images are running (also shows that the user is authorized to use the docker, while the user is otherwise not root):

docker ps

CONTAINER ID        IMAGE                                     COMMAND                  CREATED             STATUS              PORTS                                            NAMES
9acf0dd8a2e2        hyperledger/fabric-peer:x86_64-1.0.0      "peer node start"        20 seconds ago      Up 19 seconds       0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp   peer0.org1.example.com
da42dca3cbda        hyperledger/fabric-orderer:x86_64-1.0.0   "orderer"                20 seconds ago      Up 19 seconds       0.0.0.0:7050->7050/tcp                           orderer.example.com
0265c3cd86f2        hyperledger/fabric-ca:x86_64-1.0.0        "sh -c 'fabric-ca-ser"   20 seconds ago      Up 20 seconds       0.0.0.0:7054->7054/tcp                           ca.example.com
4f71895a78c0        hyperledger/fabric-couchdb:x86_64-1.0.0   "tini -- /docker-entr"   20 seconds ago      Up 19 seconds       4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp       couchdb

When I finally try to run

node query.js

I observe the following errors:

Create a client and set the wallet location
Set wallet path, and associate user  PeerAdmin  with application
Check user is enrolled, and set a query URL in the network
Make query
Assigning transaction_id:  eb03c5e69259b880433861daf57a5ac2d33e41d93cebe80a7a478a1aa2cba711
error: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: Endpoint read failed
    at /home/hla/fabric-samples/fabcar/node_modules/grpc/src/node/src/client.js:434:17
returned from query
Query result count =  1
error from query =  { Error: Endpoint read failed
    at /home/hla/fabric-samples/fabcar/node_modules/grpc/src/node/src/client.js:434:17 code: 14, metadata: Metadata { _internal_repr: {} } }
Response is  Error: Endpoint read failed

My OS:

uname -a
Linux uhost 4.4.0-92-generic #115-Ubuntu SMP Thu Aug 10 09:04:33 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

I have checked this but my node.js version is correct:

node --version
v6.11.2

npm -- version
{ fabcar: '1.0.0',
  npm: '3.10.10',
  ares: '1.10.1-DEV',
  http_parser: '2.7.0',
  icu: '56.1',
  modules: '48',
  node: '6.11.2',
  openssl: '1.0.2l',
  uv: '1.11.0',
  v8: '5.1.281.103',
  zlib: '1.2.11' }

Also, the error message is completely different. The machine has ports 8080 and 8443 in use, but when I tired to shut down the applications using them, was not helpful.

Upvotes: 1

Views: 560

Answers (1)

Farkhod Abdukodirov
Farkhod Abdukodirov

Reputation: 938

That's because you didn't follow the steps.. as it says, before query.js u should enroll the admin and register user, then it works properly. And don't pay attention to "npm WARN [email protected] No repository field", it works well. Try the following:

$docker stop $(docker ps -a -q)
$docker ps -qa|xargs docker rm
$./startFabric.sh
$cd fabric-samples/fabcar/javascript
$node enrollAdmin.js
$npm install
$node registerUser.js
$node query.js

[Output result should look like this[1]

Upvotes: 1

Related Questions