首页 > 解决方案 > 如何连接到外部部署的 Hyperledger Fabric 网络?

问题描述

fabcar我在 Azure 上的 VM 上下载并安装并启动了该示例。按照教程enrollAdminregisterUserinvoke在我在 VM 本身上执行它时工作。但是,当我尝试invoke在本地机器上执行(复制生成的连接配置文件并替换localhost为 vm 的域)并尝试连接到网络时,我收到错误:

2020-02-05T13:45:37.287Z - error: [Remote.js]: Error: Failed to connect before the deadline URL:grpcs://peer1.org2.example.com:10051 timeout:3000
2020-02-05T13:45:37.291Z - warn: [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G1:1 - endorsement failed - Error: Failed to connect before the deadline URL:grpcs://peer1.org2.example.com:10051 timeout:3000
2020-02-05T13:45:37.301Z - error: [Remote.js]: Error: Failed to connect before the deadline URL:grpcs://peer0.org1.example.com:7051 timeout:3000
2020-02-05T13:45:37.305Z - warn: [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G0:0 - endorsement failed - Error: Failed to connect before the deadline URL:grpcs://peer0.org1.example.com:7051 timeout:3000
2020-02-05T13:45:40.301Z - error: [Remote.js]: Error: Failed to connect before the deadline URL:grpcs://peer0.org2.example.com:9051 timeout:3000
2020-02-05T13:45:40.304Z - warn: [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G1:1 - endorsement failed - Error: Failed to connect before the deadline URL:grpcs://peer0.org2.example.com:9051 timeout:3000
2020-02-05T13:45:40.338Z - error: [Remote.js]: Error: Failed to connect before the deadline URL:grpcs://peer1.org1.example.com:8051 timeout:3000
2020-02-05T13:45:40.341Z - warn: [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G0:0 - endorsement failed - Error: Failed to connect before the deadline URL:grpcs://peer1.org1.example.com:8051 timeout:3000
2020-02-05T13:45:40.368Z - error: [DiscoveryEndorsementHandler]: _endorse - endorsement failed::Error: Endorsement has failed

日志peer0.org1是:

2020-02-05 13:45:40.389 UTC [grpc] warningf -> DEBU 0f0 transport: http2Server.HandleStreams failed to read frame: read tcp 172.25.0.13:7051->88.217.234.75:62583: read: connection reset by peer
2020-02-05 13:45:40.390 UTC [grpc] infof -> DEBU 0f1 transport: loopyWriter.run returning. connection error: desc = "transport is closing"

我确保所有端口都打开(在 Azure 中配置)并禁用了ufw.

那么我错过了什么?是否有任何关于如何设置不依赖于示例的生产网络的教程,因为这些示例总是依赖于一切都发生在本地或 docker 网络中的事实?

[编辑]

连接配置文件:

    "name": "first-network-org1",
    "version": "1.0.0",
    "client": {
        "organization": "Org1",
        "connection": {
            "timeout": {
                "peer": {
                    "endorser": "3000"
                }
            }
        }
    },
    "organizations": {
        "Org1": {
            "mspid": "Org1MSP",
            "peers": [
                "peer0.org1.example.com",
                "peer1.org1.example.com"
            ],
            "certificateAuthorities": [
                "ca.org1.example.com"
            ]
        }
    },
    "peers": {
        "peer0.org1.example.com": {
            "url": "grpc://host.westeurope.cloudapp.azure.com:7051",
            "grpcOptions": {
                "hostnameOverride": "peer0.org1.example.com",
                "request-timeout": 120001
            }
        },
        "peer1.org1.example.com": {
            "url": "grpc://host.westeurope.cloudapp.azure.com:8051",
            "grpcOptions": {
                "hostnameOverride": "peer1.org1.example.com",
                "request-timeout": 120001
            }
        }
    },
    "certificateAuthorities": {
        "ca.org1.example.com": {
            "url": "http://host.westeurope.cloudapp.azure.com:7054",
            "caName": "ca-org1",
            "tlsCACerts": {
                "pem": "-----BEGIN CERTIFICATE-----\nMIICUDCCAfegAwIBAgIQK3F95KrKLaFAQc2FxbmA/DAKBggqhkjOPQQDAjBzMQsw\nCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy\nYW5jaXNjbzEZMBcGA1UEChMQb3JnMS5leGFtcGxlLmNvbTEcMBoGA1UEAxMTY2Eu\nb3JnMS5leGFtcGxlLmNvbTAeFw0yMDAyMDcwOTM0MDBaFw0zMDAyMDQwOTM0MDBa\nMHMxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1T\nYW4gRnJhbmNpc2NvMRkwFwYDVQQKExBvcmcxLmV4YW1wbGUuY29tMRwwGgYDVQQD\nExNjYS5vcmcxLmV4YW1wbGUuY29tMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE\nj9KqxqKh7hIjDJJcV1qqBPj3KRXJjW6tAcIw/5gNwCcIqe2PyAQdPZsAJdOmFca5\nrtYcjrUgh9lAdLDKY0/qh6NtMGswDgYDVR0PAQH/BAQDAgGmMB0GA1UdJQQWMBQG\nCCsGAQUFBwMCBggrBgEFBQcDATAPBgNVHRMBAf8EBTADAQH/MCkGA1UdDgQiBCAA\nsJtyWNpuNWlzwdO6dPm4NcjY0vLK1+bNZ/1DmVA0+zAKBggqhkjOPQQDAgNHADBE\nAiAUm1qU7haU9mvHUL7XjyTrQGBgA4fXVuSFvAPAQUlX0QIgPQMvlC3DpW10Xwl0\nCZahvAgVnx4PjbPU4gxr9sRyDUE=\n-----END CERTIFICATE-----\n"
            },
            "httpOptions": {
                "verify": false
            }
        }
    }
}

docker-compose-files 来自您可以在此处找到的示例

java客户端的连接配置文件:

---
name: first-network-org1
version: 1.0.0
client:
  organization: Org1
  connection:
    timeout:
      peer:
        endorser: '300'
organizations:
  Org1:
    mspid: Org1MSP
    peers:
    - peer0.org1.example.com
    - peer1.org1.example.com
    certificateAuthorities:
    - ca.org1.example.com
peers:
  peer0.org1.example.com:
    url: grpc://host.westeurope.cloudapp.azure.com:7051
    grpcOptions:
      hostnameOverride: peer0.org1.example.com
  peer1.org1.example.com:
    url: grpc://host.westeurope.cloudapp.azure.com:8051
    grpcOptions:
      hostnameOverride: peer1.org1.example.com
certificateAuthorities:
  ca.org1.example.com:
    url: http://host.westeurope.cloudapp.azure.com:7054
    caName: ca-org1
    tlsCACerts:
      pem: |
        -----BEGIN CERTIFICATE-----
        MIICUTCCAfigAwIBAgIRAOQg6uxnfvgg3yqAMZweQYAwCgYIKoZIzj0EAwIwczEL
        MAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG
        cmFuY2lzY28xGTAXBgNVBAoTEG9yZzEuZXhhbXBsZS5jb20xHDAaBgNVBAMTE2Nh
        Lm9yZzEuZXhhbXBsZS5jb20wHhcNMjAwMjA3MDk1MjAwWhcNMzAwMjA0MDk1MjAw
        WjBzMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMN
        U2FuIEZyYW5jaXNjbzEZMBcGA1UEChMQb3JnMS5leGFtcGxlLmNvbTEcMBoGA1UE
        AxMTY2Eub3JnMS5leGFtcGxlLmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IA
        BCy2SE6qr2epo6P+aAH0j5ujopYEN2CzIemCZ+otF1DVuMQXS7eGCSzzuIXnYxS7
        tXD8LCUgWBoAmC1bw9EzvUqjbTBrMA4GA1UdDwEB/wQEAwIBpjAdBgNVHSUEFjAU
        BggrBgEFBQcDAgYIKwYBBQUHAwEwDwYDVR0TAQH/BAUwAwEB/zApBgNVHQ4EIgQg
        Dh/n8cBOMOCgmnwLHdmym+lVomH2IeCPb9mrBR7QM7IwCgYIKoZIzj0EAwIDRwAw
        RAIgWyr53EneGSvlRyiMR+OMeGY3S2Mli7i1kfUTdLMsVC8CIBJh06he30d6DrKS
        c/XSsRmtOxLIo+SCyebzBzVnqaYL
        -----END CERTIFICATE-----

    httpOptions:
      verify: false

标签: virtual-machinehyperledger-fabrictls1.2

解决方案


推荐阅读