使用couchdb hyperledger结构时加入对等通道时出错

使用couchdb hyperledger结构时加入对等通道时出错,couchdb,hyperledger-fabric,Couchdb,Hyperledger Fabric,我正在使用一个简单的基本网络和两个对等点,并创建一个通道。这很好,但当我尝试添加coach db功能时,返回错误: Channel created, joining Org1... Error: error getting endorser client for channel: endorser client failed to connect to peer0.org1.example.com:7051: failed to create new connection: connection

我正在使用一个简单的基本网络和两个对等点,并创建一个通道。这很好,但当我尝试添加coach db功能时,返回错误:

Channel created, joining Org1...
Error: error getting endorser client for channel: endorser client failed to connect to peer0.org1.example.com:7051: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 172.22.0.5:7051: connect: connection refused"
只有在启用coach db时才会发生这种情况,如果没有couchdb,它将创建通道并将其连接到两个对等方

当我在没有couchdb的情况下启动容器时,我使用:

docker-compose -f docker-compose-cli.yaml up -d
还有couchdb

 docker-compose -f docker-compose-cli.yaml -f docker-compose-couch.yaml up -d
docker-compose-coach.yaml包含:

version: '2'

networks:
  byfn:

services:
  couchdb0:
    container_name: couchdb0
    image: hyperledger/fabric-couchdb
    # Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
    # for CouchDB.  This will prevent CouchDB from operating in an "Admin Party" mode.
    environment:
      - COUCHDB_USER=
      - COUCHDB_PASSWORD=
    # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service,
    # for example map it to utilize Fauxton User Interface in dev environments.
    ports:
      - "5984:5984"
    networks:
      - byfn

  peer0.org1.example.com:
    environment:
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984
      # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
      # provide the credentials for ledger to connect to CouchDB.  The username and password must
      # match the username and password set for the associated CouchDB.
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    depends_on:
      - couchdb0


  couchdb1:
    container_name: couchdb1
    image: hyperledger/fabric-couchdb
    # Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
    # for CouchDB.  This will prevent CouchDB from operating in an "Admin Party" mode.
    environment:
      - COUCHDB_USER=
      - COUCHDB_PASSWORD=
    # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service,
    # for example map it to utilize Fauxton User Interface in dev environments.
    ports:
      - "7984:5984"
    networks:
      - byfn

  peer0.org2.example.com:
    environment:
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1:5984
      # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
      # provide the credentials for ledger to connect to CouchDB.  The username and password must
      # match the username and password set for the associated CouchDB.
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    depends_on:
      - couchdb1
有什么想法吗?使用couchdb时是否存在连接错误的原因


谢谢

与对等方连接时似乎出现了一些问题,因此一旦网络中断,请删除所有容器和卷。然后重新开始网络设置

并尝试在这一次单独启动docker容器,即首先使用以下方法启动所有其他容器:

docker-compose -f docker-compose-cli.yaml up -d
然后,启动couchdb容器,因为当couchdb启动并尝试搜索对等容器时,对等容器可能没有启动。因此,在所有其他容器用完后,请使用以下方法:

docker-compose -f docker-compose-couch.yaml up -d

我也有同样的问题,我修正了它,在加入频道时增加了一点延迟

如果脚本在容器启动后创建并加入通道,则couchdb容器正在运行,但其中的数据库不在运行


在脚本中创建通道之前添加“sleep 2”解决了我的问题,以确保couchdb数据库已准备好为请求提供服务。

是的,这解决了我的问题。我查看了第一个网络示例,它有一个等待couchdb启动的函数,在连接3秒后重试三次后复制此函数。