Open kalleknast opened 5 years ago
Have you tried to run the query.js script as an admin? So change "user1" to admin and change the identity to the admin identity. I feel like there might be something wrong with the add new user script. It could be possible that when you query from the CLI you are running as the root user and that's why it returned a correct value. I am trying to set up the program but I just couldn't get to your problem for some reasons.
I got stuck on js, gave it up and continued using the CLI (works fine). If you want to fix the add new user script, please do.
I updated to fabric 1.4 and fixed the "Failed to find private key for certificate..." error that was brought up before. I still haven't fixed the affiliation issue, but its not critical so I put it on hold.
Unfortunately, I cannot query the ledger. I added
query.js
, a modification of fabcarquery.js
but it fails with2019-01-24T15:09:00.316Z - error: [Network]: _initializeInternalChannel: Unable to initialize channel. Attempted to contact 1 Peers. Last error was Error: 2 UNKNOWN: Stream removed
. The last errorError: 2 UNKNOWN: Stream removed
seems to be a grpc error. I tried running the fabcar example, just the check that there was nothing wrong with my installations in general, but it worked fine.query.js
fails onconst network = await gateway.getNetwork('hachannel');
, and specifically when it tries to initialize the channel. I compared the gateway returned by the previous line:await gateway.connect(ccp, { wallet, identity: 'user1', discovery: { enabled: false } });
of fabcar and microgrid and they identical (except where they should be different).However, I can write and query to the chaincode from the cli. This works:
TLS_ROOT_CERT_FILES_PEER1=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/house01.microgrid.org/peers/peer0.house01.microgrid.org/tls/ca.crt TLS_ROOT_CERT_FILES_PEER2=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/house03.microgrid.org/peers/peer0.house03.microgrid.org/tls/ca.crt CA_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/microgrid.org/orderers/orderer.microgrid.org/msp/tlscacerts/tlsca.microgrid.org-cert.pem
peer chaincode invoke -o orderer.microgrid.org:7050 --tls true --cafile $CA_FILE -C $CHANNEL_NAME -n carecords --peerAddresses peer0.house01.microgrid.org:7051 --tlsRootCertFiles $TLS_ROOT_CERT_FILES_PEER1 --peerAddresses peer0.house03.microgrid.org:7051 --tlsRootCertFiles $TLS_ROOT_CERT_FILES_PEER2 -c '{"Args":["appendRecord","House01","2019-01-25 12:03","10"]}'
as does this:
peer chaincode query -C $CHANNEL_NAME -n carecords -c '{"Args": ["getAllRecords"]}'
returning:
[{"Key":"House01", "Record":{"amount":"10","house":"House01","time":"2019-01-25 12:03"}}]