简体   繁体   中英

Hyperledger fabric : Invalid network configuration due to missing configuration data

I am a newbie to hyperledger fabric and blockchain . I am able to configure and run examples of hyperledger fabric till now but when i renamed 'Org1' in balance transfer to 'Hospital' and also added a new organisation 'Org3'. I am able to run the application, but while trying to register a user to 'Hospital', I am facing the below issue.

network-config.json

{  
   "name":"balance-transfer",
   "x-type":"hlfv1",
   "description":"Balance Transfer Network",
   "version":"1.0",
   "channels":{  
      "mychannel":{  
         "orderers":[  
            "orderer.example.com"
         ],
         "peers":{  
            "peer0.hospital.example.com":{  
               "endorsingPeer":true,
               "chaincodeQuery":true,
               "ledgerQuery":true,
               "eventSource":true
            },
            "peer1.hospital.example.com":{  
               "endorsingPeer":false,
               "chaincodeQuery":true,
               "ledgerQuery":true,
               "eventSource":false
            },
            "peer0.org2.example.com":{  
               "endorsingPeer":true,
               "chaincodeQuery":true,
               "ledgerQuery":true,
               "eventSource":true
            },
            "peer0.org3.example.com":{  
               "endorsingPeer":true,
               "chaincodeQuery":true,
               "ledgerQuery":true,
               "eventSource":true
            }
         },
         "chaincodes":[  
            "mycc:v0"
         ]
      }
   },
   "organizations":{  
      "Hospital":{  
         "mspid":"HospitalMSP",
         "peers":[  
            "peer0.hospital.example.com",
            "peer1.hospital.example.com"
         ],
         "certificateAuthorities":[  
            "ca-hospital"
         ],
         "adminPrivateKey":{  
            "path":"artifacts/channel/crypto-config/peerOrganizations/hospital.example.com/users/Admin@hospital.example.com/msp/keystore/key"
         },
         "signedCert":{  
            "path":"artifacts/channel/crypto-config/peerOrganizations/hospital.example.com/users/Admin@hospital.example.com/msp/signcerts/Admin@hospital.example.com-cert.pem"
         }
      },
      "Org2":{  
         "mspid":"Org2MSP",
         "peers":[  
            "peer0.org2.example.com"
         ],
         "certificateAuthorities":[  
            "ca-org2"
         ],
         "adminPrivateKey":{  
            "path":"artifacts/channel/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/keystore/key"
         },
         "signedCert":{  
            "path":"artifacts/channel/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts/Admin@org2.example.com-cert.pem"
         }
      },
      "Org3":{  
         "mspid":"Org3MSP",
         "peers":[  
            "peer0.org3.example.com"
         ],
         "certificateAuthorities":[  
            "ca-org3"
         ],
         "adminPrivateKey":{  
            "path":"artifacts/channel/crypto-config/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp/keystore/key"
         },
         "signedCert":{  
            "path":"artifacts/channel/crypto-config/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp/signcerts/Admin@org3.example.com-cert.pem"
         }
      }
   },
   "orderers":{  
      "orderer.example.com":{  
         "url":"grpcs://localhost:7050",
         "grpcOptions":{  
            "ssl-target-name-override":"orderer.example.com"
         },
         "tlsCACerts":{  
            "path":"artifacts/channel/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt"
         }
      }
   },
   "peers":{  
      "peer0.hospital.example.com":{  
         "url":"grpcs://localhost:7051",
         "eventUrl":"grpcs://localhost:7053",
         "grpcOptions":{  
            "ssl-target-name-override":"peer0.hospital.example.com"
         },
         "tlsCACerts":{  
            "path":"artifacts/channel/crypto-config/peerOrganizations/hospital.example.com/peers/peer0.hospital.example.com/tls/ca.crt"
         }
      },
      "peer1.hospital.example.com":{  
         "url":"grpcs://localhost:7056",
         "eventUrl":"grpcs://localhost:7058",
         "grpcOptions":{  
            "ssl-target-name-override":"peer1.hospital.example.com"
         },
         "tlsCACerts":{  
            "path":"artifacts/channel/crypto-config/peerOrganizations/hospital.example.com/peers/peer1.hospital.example.com/tls/ca.crt"
         }
      },
      "peer0.org2.example.com":{  
         "url":"grpcs://localhost:8051",
         "eventUrl":"grpcs://localhost:8053",
         "grpcOptions":{  
            "ssl-target-name-override":"peer0.org2.example.com"
         },
         "tlsCACerts":{  
            "path":"artifacts/channel/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt"
         }
      },
      "peer0.org3.example.com":{  
         "url":"grpcs://localhost:9051",
         "eventUrl":"grpcs://localhost:9053",
         "grpcOptions":{  
            "ssl-target-name-override":"peer0.org3.example.com"
         },
         "tlsCACerts":{  
            "path":"artifacts/channel/crypto-config/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt"
         }
      }
   },
   "certificateAuthorities":{  
      "ca-hospital":{  
         "url":"https://localhost:7054",
         "httpOptions":{  
            "verify":false
         },
         "tlsCACerts":{  
            "path":"artifacts/channel/crypto-config/peerOrganizations/hospital.example.com/ca/ca.hospital.example.com-cert.pem"
         },
         "registrar":[  
            {  
               "enrollId":"admin",
               "enrollSecret":"adminpw"
            }
         ],
         "caName":"ca-hospital"
      },
      "ca-org2":{  
         "url":"https://localhost:8054",
         "httpOptions":{  
            "verify":false
         },
         "tlsCACerts":{  
            "path":"artifacts/channel/crypto-config/peerOrganizations/org2.example.com/ca/ca.org2.example.com-cert.pem"
         },
         "registrar":[  
            {  
               "enrollId":"admin",
               "enrollSecret":"adminpw"
            }
         ],
         "caName":"ca-org2"
      },
      "ca-org3":{  
         "url":"https://localhost:9054",
         "httpOptions":{  
            "verify":false
         },
         "tlsCACerts":{  
            "path":"artifacts/channel/crypto-config/peerOrganizations/org3.example.com/ca/ca.org3.example.com-cert.pem"
         },
         "registrar":[  
            {  
               "enrollId":"admin",
               "enrollSecret":"adminpw"
            }
         ],
         "caName":"ca-org3"
      }
   }
}

[2018-09-05 14:36:32.640] [ERROR] Helper - Failed to get registered user: Jim with error: Error: Invalid network configuration due to missing configuration data [2018-09-05 14:36:32.640] [DEBUG] SampleWebApp - -- returned from registering the username Jim for organization Hospital [2018-09-05 14:36:32.640] [DEBUG] SampleWebApp - Failed to register the username Jim for organization Hospital with::failed Error: Invalid network configuration due to missing configuration data

Have you replaced /keystore/key with newly generated keys after adding new Organizations? If not you need update path of the keys corresponding organizations. Whenever you generate a crypto config "key" value will change.

With error " Invalid network configuration due to missing configuration data " --> as i know from fabric-samples/balance-transfer project you need set config setting for client instant before you can call method loadFromConfig.

Here is some code you can find in file config.js in fabric-sample/balance-transer project

var hfc = require('fabric-client');

hfc.setConfigSetting('network-connection-profile-path',path.join(__dirname, 'artifacts' ,file));//file here is your network connection profile
hfc.setConfigSetting('Org1-connection-profile-path',path.join(__dirname, 'artifacts', 'org1.yaml'));
hfc.setConfigSetting('Org2-connection-profile-path',path.join(__dirname, 'artifacts', 'org2.yaml'));

In file helper.js you will see client call method loadFromConfig as below

client.loadFromConfig(hfc.getConfigSetting('network-connection-profile-path'));

I am also facing similar kind of issue, i am getting the following error message

{"success":false,"message":"failed Error: Common connection profile is missing this client's organization and mspid"}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM