从客户端发送查询请求时出错:没有可用于查询的同位体 [英] Error while sending query request from client : No peer available to query

查看:103
本文介绍了从客户端发送查询请求时出错:没有可用于查询的同位体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从客户端发送查询请求时出现以下错误.

I am getting the following error while sending query request from my client.

FabricError: No peers available to query. Errors: ["Failed to connect before the deadline 
URL:grpcs://localhost:12051","Failed to connect before the deadline 
URL:grpcs://localhost:11051"]. 

以下是我的connection-org3.json连接配置文件的一部分

Following is my the part of my connection-org3.json connection profile file

"organizations": {
        "Org3": {
            "mspid": "Org3MSP",
            "peers": [
                "peer0.org3.bc4scm.de",
                "peer1.org3.bc4scm.de"
            ],
            "certificateAuthorities": [
                "ca.org3.bc4scm.de"
            ]
        }
    },
    "peers": {
        "peer0.org3.bc4scm.de": {
            "url": "grpcs://localhost:11051",
            "tlsCACerts": {
                "path": "crypto-config/peerOrganizations/org3.bc4scm.de/tlsca/tlsca.org3.bc4scm.de-cert.pem"
            },
            "grpcOptions": {
                "ssl-target-name-override": "peer0.org3.bc4scm.de"
            }
        },
        "peer1.org3.bc4scm.de": {
            "url": "grpcs://localhost:12051",
            "tlsCACerts": {
                "path": "crypto-config/peerOrganizations/supplier.bc4scm.de/tlsca/tlsca.org3.bc4scm.de-cert.pem"
            },
            "grpcOptions": {
                "ssl-target-name-override": "peer1.org3.bc4scm.de"
            }
        }
    },
    "certificateAuthorities": {
        "ca.org3.bc4scm.de": {
            "url": "https://localhost:9054",
            "caName": "ca-supplier",
            "tlsCACerts": {
                "path": "crypto-config/peerOrganizations/org3.bc4scm.de/tlsca/tlsca.org3.bc4scm.de-cert.pem"
            },
            "httpOptions": {
                "verify": false
            }
        }
    }

以下是我的docker composer文件的一部分.

And following is a part of my docker composer file.

peer0.org3.bc4scm.de:
    container_name: peer0.org3.bc4scm.de
    extends:
      file: peer-base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer0.org3.bc4scm.de
      - CORE_PEER_ADDRESS=peer0.org3.bc4scm.de:11051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:11051
      - CORE_PEER_CHAINCODEADDRESS=peer0.org3.bc4scm.de:11052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:11052
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org3.bc4scm.de:12051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org3.bc4scm.de:11051
      - CORE_PEER_LOCALMSPID=Org3MSP
    volumes:
      - /var/run/:/host/var/run/
      - ../crypto-config/peerOrganizations/org3.bc4scm.de/peers/peer0.org3.bc4scm.de/msp:/etc/hyperledger/fabric/msp
      - ../crypto-config/peerOrganizations/org3.bc4scm.de/peers/peer0.org3.bc4scm.de/tls:/etc/hyperledger/fabric/tls
      - peer0.org3.bc4scm.de:/var/hyperledger/production
    ports:
      - 11051:11051

  peer1.org3.bc4scm.de:
    container_name: peer1.org3.bc4scm.de
    extends:
      file: peer-base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer1.org3.bc4scm.de
      - CORE_PEER_ADDRESS=peer1.org3.bc4scm.de:12051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:12051
      - CORE_PEER_CHAINCODEADDRESS=peer1.org3.bc4scm.de:12052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:12052
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org3.bc4scm.de:11051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org3.bc4scm.de:12051
      - CORE_PEER_LOCALMSPID=Org3MSP
    volumes:
      - /var/run/:/host/var/run/
      - ../crypto-config/peerOrganizations/org3.bc4scm.de/peers/peer1.org3.bc4scm.de/msp:/etc/hyperledger/fabric/msp
      - ../crypto-config/peerOrganizations/supplier.bc4scm.de/peers/peer1.org3.bc4scm.de/tls:/etc/hyperledger/fabric/tls
      - peer1.org3.bc4scm.de:/var/hyperledger/production
    ports:
    - 12051:12051

我从Fabcar示例中获取了此代码,并尝试从Org3(而不是Org1)中的客户端进行查询.我创建了一个管理员用户,然后在该组织中成功创建了一个用户.根据我的观察,我从以下代码行执行中得到了错误.

I got this code from Fabcar sample and tried to query from a client in Org3 instead of Org1. I created an admin user and then created a user in this organization successfully. According to my observations, I am getting the error from following code line execution.

const result = await contract.evaluateTransaction('queryAllProducts','123');

此问题的可能原因是什么?赞赏您对此的见解.

What is the possible reason for this issue? Appreciate your insights on this.

更新:

我检查了peer0.prg3.bs4scm.de中打开的端口

I checked opened ports in peer0.prg3.bs4scm.de

root@e52992a76c3d:/opt/gopath/src/github.com/hyperledger/fabric/peer# netstat -tulpn | grep LISTEN
tcp        0      0 127.0.0.1:9443          0.0.0.0:*               LISTEN      1/peer          
tcp        0      0 127.0.0.11:46353        0.0.0.0:*               LISTEN      -               
tcp6       0      0 :::11051                :::*                    LISTEN      1/peer          
tcp6       0      0 :::6060                 :::*                    LISTEN      1/peer          
tcp6       0      0 :::11052                :::*                    LISTEN      1/peer  

在这里,我可以看到端口11051和11052已打开并正在侦听.

Here I can see ports 11051 and 11052 are open and listening.

此外,还有一个用于安装链码的容器.

Also, there is a container for the installed chain code.

cd0b165e5186        dev-peer0.org3.bc4scm.de-scmlogic-1.0-9c7e776aa8a752e530f79d0b456f1bda28aac3f5db0af734be2f315d8d1a4f53   "/bin/sh -c 'cd /usr…"   48 seconds ago       Up 47 seconds                                                     dev-peer0.org3.bc4scm.de-scmlogic-1.0

当我查看该对等方(peer0.org3)的日志时,可以看到连续显示错误消息日志.它抱怨与org1的连接

When I look at the logs of that peer(peer0.org3) I can see floowing error log is print continuously. It is complaining about the connection with org1

019-07-06 10:26:52.278 UTC [gossip.discovery] expireDeadMembers -> WARN 164 Exiting
2019-07-06 10:26:56.381 UTC [gossip.comm] func1 -> WARN 165 peer1.org1.bc4scm.de:8051, PKIid:42214b7584f3fabcdb84e5770c62e4cf0f7c00b2a9d0441d772925882d4457a7 isn't responsive: EOF
2019-07-06 10:26:56.381 UTC [gossip.discovery] expireDeadMembers -> WARN 166 Entering [42214b7584f3fabcdb84e5770c62e4cf0f7c00b2a9d0441d772925882d4457a7]
2019-07-06 10:26:56.381 UTC [gossip.discovery] expireDeadMembers -> WARN 167 Closing connection to Endpoint: peer1.org1.bc4scm.de:8051, InternalEndpoint: , PKI-ID: 42214b7584f3fabcdb84e5770c62e4cf0f7c00b2a

推荐答案

您可以检查是否可以使用浏览器(Firefox)访问对等项. request on firefox - localhost:11051如果您可以看到响应,则意味着您的对等方可以访问,或者如果不是,则表明您的端口未针对同一端口打开,然后转到docker文件并为该端口打开该端口,然后使用docker compose向上对等方进行操作您要访问的每个对等方都是相同的.

You could check, if peer is accessible even using browser(Firefox). request on firefox - localhost:11051 if you could see the response means your peer is accessible or if not means your port is not open for the same, then go to the docker file and open the port for the same, and up the peer using docker compose , do the same for every peer you want to access.

您甚至可以使用以下命令查看对等方的日志-

Even you could check the logs of peers using following -

docker logs --follow peer0.org3.bc4scm.de

更新:---

您可以检查 CORE_PEER_GOSSIP_BOOTSTRAP&双方的CORE_PEER_GOSSIP_EXTERNALENDPOINT

**CORE_PEER_GOSSIP_BOOTSTRAP=<a list of peer endpoints within the peer's org>
CORE_PEER_GOSSIP_EXTERNALENDPOINT=<the peer endpoint, as known outside the org>**


for peer0.org3.bc4scm.de

CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org3.bc4scm.de:12051
CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org3.bc4scm.de:11051

for peer1.org3.bc4scm.de : 

CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org3.bc4scm.de:11051
CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org3.bc4scm.de:12051

  • 相应地检查端口,您的同级&上您的docker文件.
  • 这篇关于从客户端发送查询请求时出错:没有可用于查询的同位体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆