IBM-Blockchain / blockchain-vscode-extension

IBM Blockchain Platform extension for Visual Studio Code (this project is no longer active)
https://marketplace.visualstudio.com/items?itemName=IBMBlockchain.ibm-blockchain-platform
Other
266 stars 156 forks source link

Broadcast Client xxx is not connected #2600

Closed johndacost closed 4 years ago

johndacost commented 4 years ago

Description

I use the following two sdk to connect and interact with the local-network created by the extension.

package.json:

   ...
    "fabric-ca-client": "^2.2.0",
    "fabric-network": "^2.2.0",
   ...

What I did first was get the default wallets created here:

C:\Users\johnny.dacosta\.fabric-vscode\environments\chaincode-env

I copied it to my workspace and then added the `admin' identity to my wallets with the following function:

    if(this.walletProxy == null){
      //get wallet store
      this.walletProxy = await createWalletProxy(this.configService.get('localnetwork.orgWalletPath'));

      //build new identity
      const certBasePath = joinPathFromCWD(this.configService.get('localnetwork.pathIdentityCert'));
      const keyBasePath = joinPathFromCWD(this.configService.get('localnetwork.pathIdentityKey'));

      const certFilename = getFilesFromPath(certBasePath)[0];
      const keyFilename = getFilesFromPath(keyBasePath)[0];

      if(!certFilename || !keyFilename){
        throw new NotFoundException("certFilename or keyFilename not found");
      }

      const cert = readFileSyncUTF8(`${certBasePath}/${certFilename}`).toString();
      const key = readFileSyncUTF8(`${keyBasePath}/${keyFilename}`).toString();

      //add new identity
      await this.walletProxy.addIdentity(this.configService.get('localnetwork.identity'), {
        credentials: {
            certificate: cert,
            privateKey: key,
        },
        mspId: 'Org1MSP',
        type: 'X.509',
      })
    }
        //ENV
        {
      orgWalletPath: ["local-network", "wallets", "Org1", "admin", "user"],
      pathIdentityCert: ["local-network", "wallets", "Org1", "admin", "signcerts"],
      pathIdentityKey: ["local-network", "wallets", "Org1", "admin", "keystore"],
       }

image

I manage to add the new identity admin:

{"credentials":{"certificate":"-----BEGIN CERTIFICATE-----\nMIICWTCCAf+gAwIBAgIUIcgD17E4QtTsYMfeUO9Gg4SdSyIwCgYIKoZIzj0EAwIw\nfzELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNh\nbiBGcmFuY2lzY28xHzAdBgNVBAoTFkludGVybmV0IFdpZGdldHMsIEluYy4xDDAK\nBgNVBAsTA1dXVzEUMBIGA1UEAxMLZXhhbXBsZS5jb20wHhcNMjAwODEzMTIwNjAw\nWhcNMjEwODEzMTIxMTAwWjBdMQswCQYDVQQGEwJVUzEXMBUGA1UECBMOTm9ydGgg\nQ2Fyb2xpbmExFDASBgNVBAoTC0h5cGVybGVkZ2VyMQ8wDQYDVQQLEwZjbGllbnQx\nDjAMBgNVBAMTBWFkbWluMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEfkO0UxnK\nfEKmESj0GxyjSh8ljFSgXOCFqINXo66hnBb8M5XQMNE4HJFrJ5Aa0bPfvlNjCLXp\nu4MGWN3mFf1qb6N7MHkwDgYDVR0PAQH/BAQDAgeAMAwGA1UdEwEB/wQCMAAwHQYD\nVR0OBBYEFO/aOEcikRVj/j/coHPhFPS74x4WMB8GA1UdIwQYMBaAFBdnQj2qnoI/\nxMUdn1vDmdG1nEgQMBkGA1UdEQQSMBCCDmRvY2tlci1kZXNrdG9wMAoGCCqGSM49\nBAMCA0gAMEUCIQC/inkjTud4btEeECODuZQhEEZG0OgDDoSkfhNNJF82wgIgYYvF\nLK1NgJxMdYwxQYhGXSV568d+HJROXgb7+vsjd3g=\n-----END CERTIFICATE-----\n","privateKey":"-----BEGIN PRIVATE KEY-----\nMIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgGRpFEGhHS95y2Fyr\nLk6s6gd0V5D61akQC4RkEC1xYzmhRANCAAR+Q7RTGcp8QqYRKPQbHKNKHyWMVKBc\n4IWog1ejrqGcFvwzldAw0TgckWsnkBrRs9++U2MItem7gwZY3eYV/Wpv\n-----END PRIVATE KEY-----\n"},"mspId":"Org1MSP","type":"X.509","version":1}

With this identity I can getState of my asset: image

But if I try to do putState transaction I got this error:

2020-08-13T13:14:14.117Z - error: [DiscoveryHandler]: _build_endorse_group_member >> G1:0 - error on endorsement to peer0.org2.example.com:17097 error Error: Broadcast Client peer0.org2.example.com:17097 grpc://localhost:17097 is not connected
2020-08-13T13:14:14.118Z - error: [DiscoveryHandler]: _build_endorse_group_member >> G0:0 - error on endorsement to peer0.org1.example.com:17092 error Error: Broadcast Client peer0.org1.example.com:17092 grpc://localhost:17092 is not connected
[Nest] 22548   - 2020-08-13 3:14:14 PM   [ExceptionsHandler] Cannot read property 'name' of undefined +747178ms
TypeError: Cannot read property 'name' of undefined
    at newEndorsementError (C:\DEV\CIB\cib-ledger-api\node_modules\fabric-network\lib\transaction.js:33:36)
    at getResponsePayload (C:\DEV\CIB\cib-ledger-api\node_modules\fabric-network\lib\transaction.js:17:23)
    at Transaction.submit (C:\DEV\CIB\cib-ledger-api\node_modules\fabric-network\lib\transaction.js:214:28)
    at process._tickCallback (internal/process/next_tick.js:68:7)

All the peer are up: image

I'm just confused why is not working with putState transaction.

I already check my smartcontract is good I can manage to do putState operation with the extension: image

Your Environment

johndacost commented 4 years ago

Up

Jakeeyturner commented 4 years ago

Hello @johndacost

If you're using v1.0.36 of the extension you shouldn't be using

    "fabric-ca-client": "^2.2.0",
    "fabric-network": "^2.2.0",

But instead should be using 1.x of those dependencies.

If you can interact with your smart contract okay with the extension then the problem lies with either the SDK or your application.

I would recommend either raising an issue on StackOverflow or creating a JIRA.

Closing issue.

Thanks, Jake