Hyperledger fabric 为组织添加用户时,公用连接配置文件丢失错误

Hyperledger fabric 为组织添加用户时,公用连接配置文件丢失错误,hyperledger-fabric,hyperledger,Hyperledger Fabric,Hyperledger,我越来越 Error: Common connection profile is missing this client's organization and certificate authority 运行gateway.getClient().getCertificateAuthority()代码行时出错。我的连接配置文件在那里,据我了解,它没有问题 下面是我的nodejs客户端代码 'use strict'; const { FileSystemWallet, Gateway, X5

我越来越

Error: Common connection profile is missing this client's organization and certificate authority 
运行
gateway.getClient().getCertificateAuthority()
代码行时出错。我的连接配置文件在那里,据我了解,它没有问题

下面是我的nodejs客户端代码

'use strict';

const { FileSystemWallet, Gateway, X509WalletMixin } = require('fabric-network');
const path = require('path');

const ccpPath = "../connection-ogr4.json";

async function main() {
    try {

        let user = 'user2';
        // Create a new file system based wallet for managing identities.
        const walletPath = path.join(process.cwd(), 'wallet');
        const wallet = new FileSystemWallet(walletPath);
        console.log(`Wallet path: ${walletPath}`);

        const userExists = await wallet.exists(user);

        // Check to see if we've already enrolled the admin user.
        const adminExists = await wallet.exists('admin');

        // Create a new gateway for connecting to our peer node.
        const gateway = new Gateway();
        await gateway.connect(ccpPath, { wallet, identity: 'admin', discovery: { enabled: true, asLocalhost: true } });
        // Get the CA client object from the gateway for interacting with the CA.
        const ca = gateway.getClient().getCertificateAuthority()
它使用以下连接json文件

{
"name": "network-org4",
"version": "1.0.0",
"client": {
    "organization": "Org4",
    "connection": {
        "timeout": {
            "peer": {
                "endorser": "300"
            }
        }
    }
},
"organizations": {
    .......
},
"certificateAuthorities": {
    "ca.org4.bc4scm.de": {
        "url": "https://localhost:9054",
        "caName": "ca-org4",
        "tlsCACerts": {
            "path": "crypto-config/peerOrganizations/org4.bc4scm.de/tlsca/tlsca.org4.bc4scm.de-cert.pem"
        },
        "httpOptions": {
            "verify": false
        }
    }
}
}

这个问题的原因是什么?欣赏你的见解

可能缺少“渠道”、订购者、对等方。有关更多信息,请参考- 同时,下面是正在运行的代码段,您只需根据您的网络更改配置

{
  "name": "dockercompose_default",
  "version": "1.0",
  "client": {
     "organization": "org1",
     "connection": {
         "timeout": {
             "peer": {
                 "endorser": "300"
             },
             "orderer": "300"
         }
     }
 },
  "channels": {
      "common": {
          "orderers": [
              "orderer.example.com"
          ],
          "peers": {
              "peer0.org.example.com": {
                  "endorsingPeer": true,
                  "chaincodeQuery": true,
                  "ledgerQuery": true,
                  "eventSource": true
              },
              "peer1.org.example.com": {
                  "endorsingPeer": true,
                  "chaincodeQuery": false,
                  "ledgerQuery": true,
                  "eventSource": false
              }

          }
      },
      "a-b": {
          "orderers": [
              "orderer.example.com"
          ],
          "peers": {
              "peer0.org.example.com": {
                  "endorsingPeer": true,
                  "chaincodeQuery": true,
                  "ledgerQuery": true,
                  "eventSource": true
              },
              "peer1.org.example.com": {
                  "endorsingPeer": true,
                  "chaincodeQuery": false,
                  "ledgerQuery": true,
                  "eventSource": false
              }

          }
      }
  },
  "organizations": {
      "org1": {
          "mspid": "org1MSP",
          "peers": [
              "peer0.org.example.com",
              "peer1.org.example.com"
          ],
          "certificateAuthorities": [
              "ca.org.example.com"
          ],
          "adminPrivateKey": {
              "path": "../artifacts/crypto-config/peerOrganizations/org.example.com/users/Admin@org.example.com/msp/keystore/d30f6a06fa605d23da82f7f98bce3c00b37707f6363ca698331c6a1d834c47d4_sk"
          },
          "signedCert": {
              "path": "../artifacts/crypto-config/peerOrganizations/org.example.com/users/Admin@org.example.com/msp/signcerts/Admin@org.example.com-cert.pem"
          }
      }    
  },
  "orderers": {
      "orderer.example.com": {
          "url": "grpcs://localhost:7050",
          "grpcOptions": {
              "ssl-target-name-override": "orderer.example.com",
              "grpc-max-send-message-length": -1
          },
          "tlsCACerts": {
              "path": "../artifacts/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt"
          }
      }
  },
  "peers": {
      "peer0.org.example.com": {
          "url": "grpcs://localhost:7051",
          "eventUrl": "grpcs://localhost:7053",
          "grpcOptions": {
              "ssl-target-name-override": "peer0.org.example.com",
              "grpc.keepalive_time_ms": 600000
          },
          "tlsCACerts": {
              "path": "../artifacts/crypto-config/peerOrganizations/org.example.com/peers/peer0.org.example.com/tls/ca.crt"
          }
      },
      "peer1.org.example.com": {
          "url": "grpcs://localhost:7056",
          "eventUrl": "grpcs://localhost:7058",
          "grpcOptions": {
              "ssl-target-name-override": "peer1.org.example.com"
          },
          "tlsCACerts": {
              "path": "../artifacts/crypto-config/peerOrganizations/org.example.com/peers/peer1.org.example.com/tls/ca.crt"
          }
      }        
  },
  "certificateAuthorities": {
      "ca.org.example.com": {
          "url": "https://localhost:7054",
          "httpOptions": {
              "verify": true
          },
          "tlsCACerts": {
              "path": "../artifacts/crypto-config/peerOrganizations/org.example.com/peers/peer0.org.example.com/tls/ca.crt"
          },
          "registrar": [
              {
                  "enrollId": "admin",
                  "enrollSecret": "adminpw"
              }
          ],
          "caName": "ca.org.example.com"
      }        
  }
}

上面缺少Organizations对象,能否再次编辑该问题?