The Name of Hyperledger Fabric Test Network is not detected by an Application given in the samples

假如想象 提交于 2021-02-15 07:43:45

问题


I just reinstalled Fabric Samples v2.2.0 from Hyperledger Fabric repository according to the documentation.

But when I try to run asset-transfer-basic application located in fabric-samples/asset-transfer-basic/application-javascript directory by running node app.js the wallet is created and an admin and user is registered. But then it tries to invoke the function as given in app.js and shows this error

error: [Transaction]: Error: No valid responses from any peers. Errors:
    peer=peer0.org1.example.com:7051, status=500, message=error in simulation: failed to execute transaction 
aa705c10403cb65cecbd360c13337d03aac97a8f233a466975773586fe1086f6: could not launch chaincode basic_1.0:b359a077730d7
f44d6a437ad49d1da951f6a01c6d1eed4f85b8b1f5a08617fe7: error starting container: error starting container:
 API error (404): network _test not found

Response of a transaction to invoke a function

This error never occured before. But somehow after reinstalling docker and Hyperledger Fabric fabric-samples it never seems to find the network _test.

N.B. : Before reinstalling name of the network was net_test. But now when I try docker network ls it shows a network called docker_test. I am using Windows Subsystem for Linux (WSL) version 1.

NETWORK ID     NAME          DRIVER    SCOPE
b7ac05456f46   bridge        bridge    local
acaa5856b871   docker_test   bridge    local
866f58b9078d   host          host      local
4812f94efb15   none          null      local

How can I fix the issue occurring when I try to run the application?


回答1:


In my opinion, the CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE setting seems to be wrong.
you can check docker-compose.yaml or core.yaml

1. docker-compose.yaml

  • I will explain fabric-samples/test-network as targeting according to your current situation.
  • You can check in CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE in docker-compose.yaml
  • Perhaps in your case(fabric-samples/test-network), the value of ${COMPOSE_PROJECT_NAME} was not set properly, so it was set to _test.
  • Make sure the value is set correctly and change it to your network name.
# hyperledger/fabric-samples/test-network/docker/docker-compose-test-net.yaml
# based v2.2
...
  peer0.org1.example.com:
    container_name: peer0.org1.example.com
    image: hyperledger/fabric-peer:2.2
    environment:
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      # - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_test
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=docker_test
...

2. core.yaml

If you have not set the value in the docker-compose.yaml peer, you need to check the core.yaml referenced by the peer.

you can find the networkMode parameter in core.yaml

# core.yaml
...
vm:
    docker:
        hostConfig:
            # NetworkMode: host
            NetworkMode: docker_test
...

If neither is set, it will be set to the default value. However, as you see _test being logged, the wrong value have been set in one of the two section, and you need to correct the value to the value you intended.



来源:https://stackoverflow.com/questions/65932112/the-name-of-hyperledger-fabric-test-network-is-not-detected-by-an-application-gi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!