IBM / build-blockchain-insurance-app

Sample insurance application using Hyperledger Fabric
https://developer.ibm.com/patterns/build-a-blockchain-insurance-app/
Apache License 2.0
758 stars 495 forks source link

Error while running #36

Closed SirCipher closed 6 years ago

SirCipher commented 6 years ago

Hello,

I am getting the following error when running the application:

> blockchain-for-insurance@2.1.0 serve /app
> cross-env NODE_ENV=production&&node ./bin/server

/app/app/static/js
Server running on port: 3000
Default channel not found, attempting creation...
Successfully created a new default channel.
Joining peers to the default channel.
(node:21) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of undefined
    at /app/www/routers/shop.router.js:49:19
    at Generator.next (<anonymous>)
    at step (/app/bin/routers/shop.router.js:20:191)
    at /app/bin/routers/shop.router.js:20:361
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:21) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:21) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Chaincode is not installed, attempting installation...
Base container image present.
info: [packager/Golang.js]: packaging GOLANG from bcins
info: [packager/Golang.js]: packaging GOLANG from bcins
info: [packager/Golang.js]: packaging GOLANG from bcins
info: [packager/Golang.js]: packaging GOLANG from bcins
(node:21) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of undefined
    at /app/www/routers/shop.router.js:49:19
    at Generator.next (<anonymous>)
    at step (/app/bin/routers/shop.router.js:20:191)
    at /app/bin/routers/shop.router.js:20:361
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:21) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
Successfully installed chaincode on the default channel.

I get no issues when running ./build_mac.sh.

The application just hangs after I 'try to buy insurance for a bike' on this step: https://github.com/IBM/build-blockchain-insurance-app/blob/master/images/Picture3.png

Docker version 18.03.1-ce, build 9ee9f40 docker-compose version 1.21.2, build a133471 npm 5.6.0 node v8.11.3 Python 2.7.13

I have tried multiple checkouts and reinstalling dependencies. I also get the same issue on Ubuntu 18.04.

SirCipher commented 6 years ago

I get this error running on Ubuntu 18.04

`> blockchain-for-insurance@2.1.0 serve /app

cross-env NODE_ENV=production&&node ./bin/server

/app/app/static/js Server running on port: 3000 Default channel not found, attempting creation... Successfully created a new default channel. Joining peers to the default channel. Chaincode is not installed, attempting installation... Base container image present. info: [packager/Golang.js]: packaging GOLANG from bcins info: [packager/Golang.js]: packaging GOLANG from bcins info: [packager/Golang.js]: packaging GOLANG from bcins info: [packager/Golang.js]: packaging GOLANG from bcins Successfully installed chaincode on the default channel. error: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: 2 UNKNOWN: error starting container: API error (404): {"message":"network build-blockchain-insurance-app_default not found"}

at new createStatusError (/app/node_modules/grpc/src/client.js:64:15)
at /app/node_modules/grpc/src/client.js:583:15

Fatal error instantiating chaincode on some(all) peers! Error: Proposal rejected by some (all) of the peers: Error: 2 UNKNOWN: error starting container: API error (404): {"message":"network build-blockchain-insurance-app_default not found"}

at /app/www/blockchain/utils.js:248:15
at Generator.next (<anonymous>)
at step (/app/bin/blockchain/utils.js:102:191)
at /app/bin/blockchain/utils.js:102:361
at <anonymous>

npm ERR! code ELIFECYCLE npm ERR! errno 255 npm ERR! blockchain-for-insurance@2.1.0 serve: cross-env NODE_ENV=production&&node ./bin/server npm ERR! Exit status 255 npm ERR! npm ERR! Failed at the blockchain-for-insurance@2.1.0 serve script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2018-06-30T16_25_33_085Z-debug.log `

There is nothing in the npm log.

SirCipher commented 6 years ago

Another error after trying to run again:

Successfully installed chaincode on the default channel.
Successfully instantiated chaincode on all peers.
error: [Peer.js]: sendProposal - timed out after:45000
error: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: REQUEST_TIMEOUT
    at Timeout._onTimeout (/app/node_modules/fabric-client/lib/Peer.js:124:19)
    at ontimeout (timers.js:498:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:290:5)
Error getting repair orders: "list" argument must be an Array of Buffer or Uint8Array instances
{ Error: Error getting repair orders: "list" argument must be an Array of Buffer or Uint8Array instances
    at wrapError (/app/www/blockchain/utils.js:449:15)
    at Object.<anonymous> (/app/www/blockchain/repairShopPeer.js:15:11)
    at Generator.throw (<anonymous>)
    at step (/app/bin/blockchain/repairShopPeer.js:58:191)
    at /app/bin/blockchain/repairShopPeer.js:58:402
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
  inner: TypeError: "list" argument must be an Array of Buffer or Uint8Array instances
    at Function.Buffer.concat (buffer.js:446:13)
    at unmarshalResult (/app/www/blockchain/utils.js:480:21)
    at /app/www/blockchain/utils.js:368:12
    at Generator.next (<anonymous>)
    at step (/app/bin/blockchain/utils.js:102:191)
    at /app/bin/blockchain/utils.js:102:361
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7) }
error: [Peer.js]: sendProposal - timed out after:45000
error: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: REQUEST_TIMEOUT
    at Timeout._onTimeout (/app/node_modules/fabric-client/lib/Peer.js:124:19)
    at ontimeout (timers.js:498:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:290:5)
Error getting contract types for shop type P : "list" argument must be an Array of Buffer or Uint8Array instances
{ Error: Error getting contract types for shop type P : "list" argument must be an Array of Buffer or Uint8Array instances
    at wrapError (/app/www/blockchain/utils.js:449:15)
    at Object.<anonymous> (/app/www/blockchain/shopPeer.js:15:11)
    at Generator.throw (<anonymous>)
    at step (/app/bin/blockchain/shopPeer.js:125:191)
    at /app/bin/blockchain/shopPeer.js:125:402
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
  inner: TypeError: "list" argument must be an Array of Buffer or Uint8Array instances
    at Function.Buffer.concat (buffer.js:446:13)
    at unmarshalResult (/app/www/blockchain/utils.js:480:21)
    at /app/www/blockchain/utils.js:368:12
    at Generator.next (<anonymous>)
    at step (/app/bin/blockchain/utils.js:102:191)
    at /app/bin/blockchain/utils.js:102:361
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7) }
(node:21) UnhandledPromiseRejectionWarning: Error: Can't set headers after they are sent.
    at validateHeader (_http_outgoing.js:491:11)
    at ServerResponse.setHeader (_http_outgoing.js:498:3)
    at ServerResponse.header (/app/node_modules/express/lib/response.js:730:10)
    at ServerResponse.send (/app/node_modules/express/lib/response.js:170:12)
    at ServerResponse.json (/app/node_modules/express/lib/response.js:256:15)
    at /app/www/routers/shop.router.js:46:9
    at Generator.throw (<anonymous>)
    at step (/app/bin/routers/shop.router.js:20:191)
    at /app/bin/routers/shop.router.js:20:402
    at <anonymous>
(node:21) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:21) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
lll2657 commented 6 years ago

Before solving these issues, please use ./clean.sh first to clean your docker containers.

Join Peer Issue

Symptoms: Stuck inJoining peers to the default channel. Timeout: error: [Peer.js]: sendProposal - timed out after:45000 (node:21) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of undefined

The reason for the issue is that the peers fail to join the channel because they are not ready to be used by the callback function in joinChannel() in ./web/www/blockchain/utils.js. In order to fix this, we need to separate the functions in the line docker-compose up -d, so that the containers are built and waited long enough for all the peers to be ready.

So all you need to do is to change build_ubuntu to the code below (similarly for build_mac):

#!/bin/bash
cp ./binary_ubuntu/* .
export FABRIC_CFG_PATH=$PWD
sh ./ibm_fabric.sh
sh ./docker-images.sh
sleep 5
docker-compose up --no-start
sleep 60
docker-compose up -d

Network not found Issue

Symptoms: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: 2 UNKNOWN: error starting container: API error (404): {"message":"network build-blockchain-insurance-app_default not found"}

The reason for the issue is that the network name cannot be found. To solve this, run docker network ls to figure out what the actual network name is, such as "buildblockchaininsuranceapp_default". Go to ./peer-base.yaml and change CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE to the corresponding network name. Clean the docker containers with ./clean.sh and then rebuild the app again.

SirCipher commented 6 years ago

Hello,

Thank you for your response. Unfortunately, I still get the same issue.


> blockchain-for-insurance@2.1.0 serve /app
> cross-env NODE_ENV=production&&node ./bin/server

/app/app/static/js
Server running on port: 3000
Default channel not found, attempting creation...
Successfully created a new default channel.
Joining peers to the default channel.
Chaincode is not installed, attempting installation...
Base container image present.
info: [packager/Golang.js]: packaging GOLANG from bcins
info: [packager/Golang.js]: packaging GOLANG from bcins
info: [packager/Golang.js]: packaging GOLANG from bcins
info: [packager/Golang.js]: packaging GOLANG from bcins
Successfully installed chaincode on the default channel.
(node:23) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of undefined
    at /app/www/routers/shop.router.js:49:19
    at Generator.next (<anonymous>)
    at step (/app/bin/routers/shop.router.js:20:191)
    at /app/bin/routers/shop.router.js:20:361
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:23) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:23) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Do you have any other ideas?

SirCipher commented 6 years ago

I've got it up and running now. A second error came later on that mentioned the incorrect name of the chain. Thank you for your help.

vasanthk97 commented 6 years ago

I've got it up and running now. A second error came later on that mentioned the incorrect name of the chain. Thank you for your help.

How did you solve this issue, please help i'm stuck on it.

kuppuswamybp commented 6 years ago

Even after changing the build_ubuntu and peer-base.yaml and rebuilding the application still facing the same issue error: [Peer.js]: sendProposal - timed out after:45000 error: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: REQUEST_TIMEOUT at Timeout._onTimeout (/app/node_modules/fabric-client/lib/Peer.js:124:19) at ontimeout (timers.js:498:11) at tryOnTimeout (timers.js:323:5) at Timer.listOnTimeout (timers.js:290:5) Fatal error instantiating chaincode on some(all) peers! Error: Proposal rejected by some (all) of the peers: Error: REQUEST_TIMEOUT at /app/www/blockchain/utils.js:248:15 at Generator.next () at step (/app/bin/blockchain/utils.js:102:191) at /app/bin/blockchain/utils.js:102:361 at at process._tickCallback (internal/process/next_tick.js:188:7). Please suggest for the same.

d-jeph commented 5 years ago

Hello,

I am getting the following error when running the application:

> blockchain-for-insurance@2.1.0 serve /app
> cross-env NODE_ENV=production&&node ./bin/server

/app/app/static/js
Server running on port: 3000
Default channel not found, attempting creation...
Successfully created a new default channel.
Joining peers to the default channel.
(node:21) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of undefined
    at /app/www/routers/shop.router.js:49:19
    at Generator.next (<anonymous>)
    at step (/app/bin/routers/shop.router.js:20:191)
    at /app/bin/routers/shop.router.js:20:361
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:21) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:21) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Chaincode is not installed, attempting installation...
Base container image present.
info: [packager/Golang.js]: packaging GOLANG from bcins
info: [packager/Golang.js]: packaging GOLANG from bcins
info: [packager/Golang.js]: packaging GOLANG from bcins
info: [packager/Golang.js]: packaging GOLANG from bcins
(node:21) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of undefined
    at /app/www/routers/shop.router.js:49:19
    at Generator.next (<anonymous>)
    at step (/app/bin/routers/shop.router.js:20:191)
    at /app/bin/routers/shop.router.js:20:361
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:21) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
Successfully installed chaincode on the default channel.

I get no issues when running ./build_mac.sh.

The application just hangs after I 'try to buy insurance for a bike' on this step: https://github.com/IBM/build-blockchain-insurance-app/blob/master/images/Picture3.png

Docker version 18.03.1-ce, build 9ee9f40 docker-compose version 1.21.2, build a133471 npm 5.6.0 node v8.11.3 Python 2.7.13

I have tried multiple checkouts and reinstalling dependencies. I also get the same issue on Ubuntu 18.04.

@SirCipher how did you resolve this?