收到来自对等方的错误响应:message = 2 UNKNOWN:访问被拒绝

时间:2019-10-05 13:25:18

标签: hyperledger-fabric

我已经能够引导一个Fabric网络:

  • 个人订购者
  • 三个组织(每个组织都有一个CA和一个对等方)
  • 两个渠道:公共渠道(所有3个组织)和私有渠道(org1和org2)

在CLI中,一切-链码安装,实例化,调用和查询-都可以完美运行。但是,当我尝试使用nodejs客户端(Fabcar api)时,出现以下拒绝访问错误:

$ ts-node invoke.ts 
Wallet path: /Users/moazzemhossen/ws/hlf/scratch/api/src/wallet
2019-10-05T11:43:04.448Z - warn: [Transaction]: _validatePeerResponses: Received error response from peer: message=2 UNKNOWN: access denied: channel [public-channel] creator org [Org1MSP], stack=Error: 2 UNKNOWN: access denied: channel [public-channel] creator org [Org1MSP]
    at Object.exports.createStatusError (/Users/moazzemhossen/ws/hlf/scratch/api/node_modules/grpc/src/common.js:91:15)
    at Object.onReceiveStatus (/Users/moazzemhossen/ws/hlf/scratch/api/node_modules/grpc/src/client_interceptors.js:1204:28)
    at InterceptingListener._callNext (/Users/moazzemhossen/ws/hlf/scratch/api/node_modules/grpc/src/client_interceptors.js:568:42)
    at InterceptingListener.onReceiveStatus (/Users/moazzemhossen/ws/hlf/scratch/api/node_modules/grpc/src/client_interceptors.js:618:8)
    at callback (/Users/moazzemhossen/ws/hlf/scratch/api/node_modules/grpc/src/client_interceptors.js:845:24), code=2, , details=access denied: channel [public-channel] creator org [Org1MSP]
Failed to submit transaction: TypeError: Cannot read property 'name' of undefined

这是我的configtx.yaml

Organizations:
  - &OrdererOrg
    Name: OrdererOrg
    ID: OrdererMSP
    MSPDir: crypto-config/ordererOrganizations/ord/msp
    Policies:
      Readers:
        Type: Signature
        Rule: "OR('OrdererMSP.member')"
      Writers:
        Type: Signature
        Rule: "OR('OrdererMSP.member')"
      Admins:
        Type: Signature
        Rule: "OR('OrdererMSP.admin')"

  - &Org1
    Name: Org1MSP
    ID: Org1MSP
    MSPDir: crypto-config/peerOrganizations/org1/msp
    Policies:
      Readers:
        Type: Signature
        Rule: "OR('Org1MSP.member')"
      Writers:
        Type: Signature
        Rule: "OR('Org1MSP.member')"
      Admins:
        Type: Signature
        Rule: "OR('Org1MSP.member')"
    AnchorPeers:
      - Host: peer0.org1
        Port: 7051

  - &Org2
    Name: Org2MSP
    ID: Org2MSP
    MSPDir: crypto-config/peerOrganizations/org2/msp
    Policies:
      Readers:
        Type: Signature
        Rule: "OR('Org2MSP.member')"
      Writers:
        Type: Signature
        Rule: "OR('Org2MSP.member')"
      Admins:
        Type: Signature
        Rule: "OR('Org2MSP.member')"

    AnchorPeers:
      - Host: peer0.org2
        Port: 7051

  - &Org3
    Name: Org3MSP
    ID: Org3MSP
    MSPDir: crypto-config/peerOrganizations/org3/msp
    Policies:
      Readers:
        Type: Signature
        Rule: "OR('Org3MSP.member')"
      Writers:
        Type: Signature
        Rule: "OR('Org3MSP.member')"
      Admins:
        Type: Signature
        Rule: "OR('Org3MSP.member')"

    AnchorPeers:
      - Host: peer0.org3
        Port: 7051
Capabilities:
  Channel: &ChannelCapabilities
    V1_4_3: true
    V1_3: false
    V1_1: false
  Orderer: &OrdererCapabilities
    V1_4_2: true
    V1_1: false
  Application: &ApplicationCapabilities
    V1_4_2: true
    V1_3: false
    V1_2: false
    V1_1: false
Application: &ApplicationDefaults
  Organizations:
  Policies:
    Readers:
      Type: ImplicitMeta
      Rule: "ANY Readers"
    Writers:
      Type: ImplicitMeta
      Rule: "ANY Writers"
    Admins:
      Type: ImplicitMeta
      Rule: "MAJORITY Admins"

  Capabilities:
    <<: *ApplicationCapabilities
Orderer: &OrdererDefaults
  OrdererType: solo
  Addresses:
    - ord1.ord:7050
  BatchTimeout: 2s
  BatchSize:
    MaxMessageCount: 10
    AbsoluteMaxBytes: 99 MB
    PreferredMaxBytes: 512 KB
  Organizations:
  Policies:
    Readers:
      Type: ImplicitMeta
      Rule: "ANY Readers"
    Writers:
      Type: ImplicitMeta
      Rule: "ANY Writers"
    Admins:
      Type: ImplicitMeta
      Rule: "MAJORITY Admins"
    BlockValidation:
      Type: ImplicitMeta
      Rule: "ANY Writers"
Channel: &ChannelDefaults
  Policies:
    Readers:
      Type: ImplicitMeta
      Rule: "ANY Readers"
    Writers:
      Type: ImplicitMeta
      Rule: "ANY Writers"
    Admins:
      Type: ImplicitMeta
      Rule: "MAJORITY Admins"
  Capabilities:
    <<: *ChannelCapabilities

Profiles:
  OrdererGenesis:
    <<: *ChannelDefaults
    Orderer:
      <<: *OrdererDefaults
      Organizations:
        - *OrdererOrg
      Capabilities:
        <<: *OrdererCapabilities
    Consortiums:
      SampleConsortium:
        Organizations:
          - *Org1
          - *Org2
          - *Org3
  PublicChannel:
    Consortium: SampleConsortium
    <<: *ChannelDefaults
    Application:
      <<: *ApplicationDefaults
      Organizations:
        - *Org1
        - *Org2
        - *Org3
      Capabilities:
        <<: *ApplicationCapabilities
  PrivateChannel:
    Consortium: SampleConsortium
    <<: *ChannelDefaults
    Application:
      <<: *ApplicationDefaults
      Organizations:
        - *Org1
        - *Org2
      Capabilities:
        <<: *ApplicationCapabilities

以及Fabcar应用程序api的连接配置文件:

{
    "name": "fabcar-network",
    "version": "1.0.0",
    "client": {
        "tlsEnable": false,
        "adminUser": "admin",
        "adminPassword": "adminpw",
        "enableAuthentication": false,
        "organization": "Org1",
        "connection": {
            "timeout": {
                "peer": {
                    "endorser": "6000"
                },
                "orderer": "6000"
            }
        }
    },
    "channels": {
        "public-channel": {
            "orderers": [
                "ord1.ord"
            ],
            "peers": {
                "peer0.org1": {}
            }
        }
    },
    "organizations": {
        "Org1": {
            "mspid": "Org1MSP",
            "peers": [
                "peer0.org1"
            ],
            "certificateAuthorities": [
                "ca.org1"
            ],
            "adminPrivateKey": {
                "path": "/var/hyperledger/crypto-config/peerOrganizations/org1/users/Admin@org1/msp/keystore/a73bb47d0112bba5d94ffa1463ea60514f407ebc2e0f953aa89633934da63d39_sk"
            },
            "signedCert": {
                "path": "/var/hyperledger/crypto-config/peerOrganizations/org1/users/Admin@org1/msp/signcerts/Admin@org1-cert.pem"
            }
        }
    },
    "orderers": {
        "ord1.ord": {
            "url": "grpc://0.0.0.0:7050"
        }
    },
    "peers": {
        "peer0.org1": {
            "url": "grpc://0.0.0.0:7051",
            "events": "grpc:0.0.0.0:7053",
            "grpcOptions": {
                "ssl-target-name-override": "peer0.org1"
            }
        }
    },
    "certificateAuthorities": {
        "ca.org1": {
            "url": "http://0.0.0.0:7054",
            "httpOptions": {
                "verify": false
            },
            "tlsCACerts": {
                "path": "/var/hyperledger/crypto-config/peerOrganizations/org1/tlsca/tlsca.org1-cert.pem"
            },
            "caName": "ca.org1",
            "registrar": [
                {
                    "enrollId": "admin",
                    "enrollSecret": "adminpw"
                }
            ]
        }
    }
}

0 个答案:

没有答案