Search code examples
hyperledger-fabrichyperledger

Hyperledger, blockchain explorer launching fails. Can't connect to mychannel


By using this tutorial i have downloaded fabric's files by this command:

sudo curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/bootstrap.sh| sudo bash -s

I have added sudo because docker commands in my system can only work in that way.

After that, I went to directory fabric-samples/test-network and started fabric:

sudo ./network up

It started successfully. Then I have created channel:

sudo ./network createChannel

Which gave me this result:

Channel 'mychannel' joined

After that I have uploaded chaincode of asset-transfer-basic like this:

sudo ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go

Then I have created separate folder explorer and used these commands:

sudo wget https://raw.githubusercontent.com/hyperledger/blockchain- explorer/main/examples/net1/config.json
sudo wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/examples/net1/connection-profile/test-network.json -P connection-profile
sudo wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/docker-compose.yaml
sudo cp -r ../fabric-samples/test-network/organizations/ .

The docker-compose.yaml was changed into this:

volumes:
      - ./config.json:/opt/explorer/app/platform/fabric/config.json
      - ./connection-profile:/opt/explorer/app/platform/fabric/connection-profile
      - ./organizations:/tmp/crypto
      - walletstore:/opt/explorer/wallet

Then on test-network.json I have changed these fields into these:

 "adminPrivateKey": {
   "path": "/tmp/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore/priv_sk"
  },
 "peers": ["peer0.org1.example.com"],
 "signedCert": {
   "path": "/tmp/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp/signcerts/[email protected]"
  }

After all of this, I launched it by command sudo docker-compose up I get that kind of error in explorer:

[2022-04-21T16:32:34.374] [INFO] FabricConfig - FabricConfig, this.config.channels  mychannel
2022-04-21T16:32:34.630Z - error: [DiscoveryService]: send[mychannel] - Channel:mychannel received discovery error:access denied
[2022-04-21T16:32:34.631] [ERROR] FabricClient - Error: DiscoveryService: mychannel error: access denied
    at DiscoveryService.send (/opt/explorer/node_modules/fabric-common/lib/DiscoveryService.js:363:11)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async NetworkImpl._initializeInternalChannel (/opt/explorer/node_modules/fabric-network/lib/network.js:279:13)
at async NetworkImpl._initialize (/opt/explorer/node_modules/fabric-network/lib/network.js:231:9)
at async Gateway.getNetwork (/opt/explorer/node_modules/fabric-network/lib/gateway.js:330:9)

Why access denied? Did I miss something?


Solution

  • I'm going to answer for my own question. I hope it will help somebody. The solution of this problem was pretty simple (it's slightly embarrassing)

    I needed to set proper volumes in this part:

    volumes:
       - walletstore:/opt/explorer/wallet
    

    Should be

    volumes:
       - /path/to/somewhere:/opt/explorer/wallet
    

    It couldn't connect to my channel because it couldn't assign wallet files.