简体   繁体   English

无法通过 NodeJS 查询/调用 Hyperledger Fabric Peers(在 docker swarm 网络中) - GRPC/S 截止日期错误

[英]Failed to query/invoke Hyperledger Fabric Peers(in a docker swarm network) via NodeJS - GRPC/S deadline Error

Process I've installed, queried, invoked fabcar chaincode via CLI.过程中,我已经安装,查询,通过CLI调用fabcar chaincode。 Everything was successful.一切都很成功。

enrolAdmin.js and registerUser.js successfully worked. enrolAdmin.js 和 registerUser.js 成功运行。

BUT when I ran query.js I've got the following error但是当我运行query.js时出现以下错误

Error错误

error: [Remote.js]: Error: Failed to connect before the deadline URL:grpc://192.168.56.171:7051
error: [Remote.js]: Error: Failed to connect before the deadline URL:grpc://192.168.56.171:8051
error: [Network]: _initializeInternalChannel: Unable to initialize channel. Attempted to contact 2 Peers. Last error was Error: Failed to connect before the deadline URL:grpc://192.168.56.171:8051
Failed to evaluate transaction: Error: Unable to initialize channel. Attempted to contact 2 Peers. Last error was Error: Failed to connect before the deadline URL:grpc://192.168.56.171:8051

FYI - I've tested the same with both TLS disabled and enabled.仅供参考 - 我已经在禁用和启用 TLS 的情况下进行了相同的测试。 Still fails还是失败

Environment I've extended Hyperledger Fabric first-network e2e to work in multiple hosts with the help of docker swarm.环境我在 docker swarm 的帮助下扩展了 Hyperledger Fabric first-network e2e 以在多个主机上工作。

Connection profile ( without TLS) as follows连接配置文件(TLS)如下

{
    "name": "first-network",
    "version": "1.0.0",
    "client": {
        "organization": "Org1",
        "connection": {
            "timeout": {
                "peer": {
                    "endorser": "300"
                },
                "orderer": "300"
            }
        }
    },
    "channels": {
        "mychannel": {
            "orderers": [
                "orderer.example.com",
            ],
            "peers": {
                "peer0.org1.example.com": {},
                "peer1.org1.example.com": {},
                "peer0.org2.example.com": {},
                "peer1.org2.example.com": {}
            }
        }
    },
    "organizations": {
        "Org1": {
            "mspid": "Org1MSP",
            "peers": [
                "peer0.org1.example.com",
                "peer1.org1.example.com"
            ],
            "certificateAuthorities": [
                "ca.org1.example.com"
            ]
        },
        "Org2": {
            "mspid": "Org2MSP",
            "peers": [
                "peer0.org2.example.com",
                "peer1.org2.example.com"
            ],
            "certificateAuthorities": [
                "ca.org2.example.com"
            ]
        }
    },
    "orderers": {
        "orderer.example.com": {
            "url": "grpc://192.168.56.170:7050"
        }
    },
    "peers": {
        "peer0.org1.example.com": {
            "url": "grpc://192.168.56.171:7051"
        },
        "peer1.org1.example.com": {
            "url": "grpc://192.168.56.171:8051"
        },
        "peer0.org2.example.com": {
            "url": "grpc://192.168.56.172:7051"
        },
        "peer1.org2.example.com": {
            "url": "grpc://192.168.56.172:8051"
        }
    },
    "certificateAuthorities": {
        "ca.org1.example.com": {
            "url": "http://192.168.56.171:7054",
            "caName": "ca.org1.example.com"
        },
        "ca.org2.example.com": {
            "url": "http://192.168.56.172:7054",
            "caName": "ca.org2.example.com"
        }
    }
}

Snippet of docker-compose file structure as follows, docker-compose 文件结构的片段如下,

networks:
  hyperledger:
        external: 
            name: hyperledger
  peer0.org1.example.com:
    container_name: peer0.org1.example.com
    -----------------------
    -----------------------
    -----------------------
    ports:
      - 7051:7051
    networks:
      hyperledger:
        aliases:
         - peer0.org1.example.com 

Expected Result - Connect to Hyperledger docker swarm containers via NodeJS预期结果- 通过 NodeJS 连接到 Hyperledger docker swarm 容器

I recommend use domain.我建议使用域。 modify /etc/hosts修改 /etc/hosts

192.168.100.100 peer0.org1.example.com
192.168.100.100 peer1.org1.example.com
192.168.100.100 orderer.example.com
192.168.100.100 orderer.example.com
192.168.100.100 orderer3.example.com
192.168.100.100 orderer4.example.com
192.168.100.100 orderer5.example.com

modify connection-org1.json修改 connection-org1.json

"peers": {
    "peer0.org1.example.com": {
        "url": "grpcs://peer0.org1.example.com:7051",


"peers": {
    "peer0.org1.example.com": {
        "url": "grpcs://peer0.org1.example.com:7051",

modify code修改代码

await gateway.connect(ccpPath, { wallet, identity: 'user1', discovery: { enabled: true, asLocalhost: false } });

I have found the solution for the issue.我已经找到了该问题的解决方案。 Make sure telnet works to the desired container from outside the network.确保 telnet 可以从网络外部访问所需的容器。 By running通过跑步

telnet 192.168.128.171 7051

If Telnet doesn't work --> The issue must because that ports are not published/exposed properly.如果 Telnet 不起作用--> 问题一定是因为该端口未正确发布/公开。 1st check the following,第一检查以下,

Make sure CORE_PEER_LISTENADDRESS is set to listen to desired port in docker-compose files.确保 CORE_PEER_LISTENADDRESS 设置为侦听 docker-compose 文件中的所需端口。 As follows, For peer0.org1.eaxmple.com --> 7051,如下,对于peer0.org1.eaxmple.com --> 7051,

CORE_PEER_LISTENADDRESS=0.0.0.0:7051

If Telnet works --> Check the connection profile.如果 Telnet 工作--> 检查连接配置文件。 If TLS is enabled, make sure the tls certificates/PEM files are passed properly and connection is set to GRPCS (not GRPC)如果启用了 TLS,请确保正确传递 tls 证书/PEM 文件并将连接设置为GRPCS (而非 GRPC)

Connection Profile连接配置文件

            "certificateAuthorities": [

                "ca.org1.example.com"

            ],

            "adminPrivateKey": {

                "path": "crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX_sk"

            },

            "signedCert": {

                "path": "crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem"

            }
        "peer0.org1.example.com": {

            "url": "grpcs://192.168.128.171:7051",

            "grpcOptions": {

                "ssl-target-name-override": "peer0.org1.example.com",

                "request-timeout": 120001

            },

            "tlsCACerts": {

                "path": "crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/tlscacerts/tlsca.org1.example.com-cert.pem"

            }

        },

Have a look at the following link for further reference https://fabric-sdk-node.github.io/tutorial-network-config.html查看以下链接以获取进一步参考https://fabric-sdk-node.github.io/tutorial-network-config.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Hyperledger Fabric 错误 - 尝试联系 2 个对等点。 最后一个错误是错误:在截止日期前无法连接 - Hyperledger Fabric Error - Attempted to contact 2 Peers. Last error was Error: Failed to connect before the deadline Hyperledger Fabric - 多主机网络 - Docker Swarm - Hyperledger Fabric - Multi Host Network - Docker Swarm HyperLedger Fabric 和 Docker Swarm:握手失败,出现致命错误 SSL_ERROR_SSL - HyperLedger Fabric and Docker Swarm: Handshake failed with fatal error SSL_ERROR_SSL 将超级账本结构部署到 docker 群 - Deploy hyperledger fabric to docker swarm Docker Swarm 部署 Hyperledger Fabric - Docker Swarm Deployment Hyperledger Fabric 使用超级账本结构 2.0 提交链代码调用/查询时出错 - Error in committed chaincode invoke/query with hyperledger fabric 2.0 在扩展Hyperledger Fabfab实例与其他同伴时出错 - Error while extending the Hyperledger fabric fabcar example with additional peers Hyperledger Fabric-Docker容器错误 - hyperledger fabric - docker container error Hyperledger 测试网络 - 无法创建新连接:超出上下文期限 - Hyperledger Test Network - failed to create new connection: context deadline exceeded 安装 Hyperledger Fabric 泊坞窗图像失败 - Failed Installing Hyperledger Fabric docker images
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM