问:
How can I get links between models on BIM 360?
I am trying to build a script that transfers files from the Project Files subfolders to the Plans subfolders.

In my BIM 360 Docs I have .rvt models that are linked (e.g. HVAC model linked to the architecture 3D model). When I download a linked model (manually or via the Forge API), I get a .zip file with all the linked models in it.

Is it possible to check which models are linked to an item via the Forge APIs and also in which folder those linked models are stored?

Thank you for your help.

Edit: I tried getting those links by calling versions/:version_id/relationships/refs, but it only shows copies I made from the file.

The links I am trying the get are created in Revit via Insert > Link Revit > Add... and then selecting a file from BIM 360.

Also, when uploading this kind of file (with linked models) manually, to do it correctly I need to select the "upload linked files" option in BIM 360 and then select the parent file.

答:
I also had a lot of trouble to follow links between Revit files on BIM360/ACC and after a lot of research, the situation seems as follows:

There is no way to get links/references for models that are composite designs (ie. downloadable as zip files)

For non-composite models, your mentioned relationships/refs endpoint will return incoming and outgoing references correctly

To check wether an item (revit file) is a composite design or not, check projects/:project_id/items/:item_id/versions. This will return an array of versions, each with attributes.extension.data.isCompositeDesign (bool). If you find versions with isCompositeDesign=false, you can use the relationships/refs endpoint to get all references (of that version).

A model will become composite once there are referenced items with unpublished changes. See here for more details on composite design and here for troubleshooting the creation of cloud compatible links/references.

Models that are composite designs will contain all referenced files including the source file in one zip file. It is noteworthy that the zip file will not contain referenced references, ie. it does not follow references. In other words: If a composite design model references models that are composite designs themselves, the zip file will not contain the zip file of the composite design reference, but only the reference (rvt file) without its references. This makes it very hard, if not impossible, to use design automation in real world scenarios where models often contain sub-references (reference of a reference) and not all the models along the reference chain are untouched, published models.


来源: stackexchange

问:
How to get rid of files which end in .Identifier in Laravel
I cloned a laravel-8 sail project via gitlab but everywhere in every folder which containing files there is a file which ends in .Identifier
I don't know where they come from. There may be 1000 files like this in the project.

My question is:

How can I get rid of those files which endr with .Identifier?

Is there some kind of Ubuntu or docker command that searches the entire project for such file which ends in .Identifier and then deletes them?

Maybe phpStorm has such a function?

答: If you are on Linux machine, then open terminal in you project folder and run rm *.Identifier. And if you are on Windows machine then open command prompt in your project folder and run del *.Identifier. This will do the trick for you.

ContentLicense: CC BY-SA 4.0


问:
Program stuck at creating driver instance
I have program that uses threading that opens several drivers same time and all doing different search online.
But when I start running the program, some driver work fine, but some driver will stuck at the creating driver instance stage.

Those drivers just stuck there forever.

This is the code that those drivers stopped:

```<code>browser = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
</code>```

Any idea that what went wrong? Or what are the ways to find out what went wrong? Since the program stuck there, I don't know how to get the error from it.
The Whole function that create drivers as follows:

```<code>for driver_threads in range(Driver_Count):
    Driver_Creation = Thread(target=createDriverInstance,args=(driver_threads,"Hide"))
    Driver_Creation.start()

def createDriverInstance(driver_threads, display):
    chrome_options = Options()
    chrome_options.binary_location=chrome_binary_location # I have declare the location somewhere
    if(display=="Hide"):
        chrome_options.add_argument('--headless')
        chrome_options.add_argument('--disable-gpu')
    chrome_options.add_argument("--log-level=3")
    chrome_options.add_experimental_option('excludeSwitches', ['enable-logging'])
    browser = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
    return browser
</code>```

答:
Change the current browser variable
To :

```<code>browser =  webdriver.Chrome(options=chrome_options)
</code>```

This
I think it is because it is trying to download chromedriver So
:)))

Body:
I have program that uses threading that opens several drivers same time and all doing different search online.
But when I start running the program, some driver work fine, but some driver will stuck at the creating driver instance stage.

Those drivers just stuck there forever.

This is the code that those drivers stopped:

browser = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)

Any idea that what went wrong? Or what are the ways to find out what went wrong? Since the program stuck there, I don't know how to get the error from it.
The Whole function that create drivers as follows:

for driver_threads in range(Driver_Count):
    Driver_Creation = Thread(target=createDriverInstance,args=(driver_threads,"Hide"))
    Driver_Creation.start()

def createDriverInstance(driver_threads, display):
    chrome_options = Options()
    chrome_options.binary_location=chrome_binary_location # I have declare the location somewhere
    if(display=="Hide"):
        chrome_options.add_argument('--headless')
        chrome_options.add_argument('--disable-gpu')
    chrome_options.add_argument("--log-level=3")
    chrome_options.add_experimental_option('excludeSwitches', ['enable-logging'])
    browser = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
    return browser

Body:
Change the current browser variable
To :

browser =  webdriver.Chrome(options=chrome_options)

This
I think it is because it is trying to download chromedriver So
:)))


问:
Chaincode Deployment Failed on Peer1
Hi I am getting the following Error when Installing the chaincode. I have tried everything but still no clue what is happening.Please help me on this.

2022-01-28 12:36:06.833 IST 0001 INFO [chaincodeCmd] ClientWait -> txid [cd68692e297f8bee9e6dbfdd726467901875683e411c1fb8b1580b7ab358b952] committed with status (MVCC_READ_CONFLICT) at localhost:8051
Error: transaction invalidated with status (MVCC_READ_CONFLICT)
Chaincode definition approved on peer1.org1 on channel 'mychannel' failed
Deploying chaincode failed

This is configtx-

```<code>Organizations:
    - &OrdererOrg
        Name: OrdererOrg
        ID: OrdererMSP
        MSPDir: ../organizations/ordererOrganizations/example.com/msp

        Policies:
            Readers:
                Type: Signature
                Rule: "OR('OrdererMSP.member')"
            Writers:
                Type: Signature
                Rule: "OR('OrdererMSP.member')"
            Admins:
                Type: Signature
                Rule: "OR('OrdererMSP.admin')"

        OrdererEndpoints:
            - orderer.example.com:7050

    - &Org1
        Name: Org1MSP
        ID: Org1MSP
        MSPDir: ../organizations/peerOrganizations/org1.example.com/msp

        Policies:
            Readers:
                Type: Signature
                Rule: "OR('Org1MSP.admin', 'Org1MSP.peer', 'Org1MSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('Org1MSP.admin', 'Org1MSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('Org1MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org1MSP.peer')"

    - &Org2
        Name: Org2MSP
        ID: Org2MSP

        MSPDir: ../organizations/peerOrganizations/org2.example.com/msp

        Policies:
            Readers:
                Type: Signature
                Rule: "OR('Org2MSP.admin', 'Org2MSP.peer', 'Org2MSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('Org2MSP.admin', 'Org2MSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('Org2MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org2MSP.peer')"

    - &Org3
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: Org3MSP

        # ID to load the MSP definition as
        ID: Org3MSP

        MSPDir: ../organizations/peerOrganizations/org3.example.com/msp

        # Policies defines the set of policies at this level of the config tree
        # For organization policies, their canonical path is usually
        #   /Channel/<Application|Orderer>/<OrgName>/<PolicyName>
        Policies:
            Readers:
                Type: Signature
                Rule: "OR('Org3MSP.admin', 'Org3MSP.peer', 'Org3MSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('Org3MSP.admin', 'Org3MSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('Org3MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org3MSP.peer')"

    - &Org4
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: Org4MSP

        # ID to load the MSP definition as
        ID: Org4MSP

        MSPDir: ../organizations/peerOrganizations/org4.example.com/msp

        # Policies defines the set of policies at this level of the config tree
        # For organization policies, their canonical path is usually
        #   /Channel/<Application|Orderer>/<OrgName>/<PolicyName>
        Policies:
            Readers:
                Type: Signature
                Rule: "OR('Org4MSP.admin', 'Org4MSP.peer', 'Org4MSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('Org4MSP.admin', 'Org4MSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('Org4MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org4MSP.peer')"

################################################################################
#
#   SECTION: Capabilities
#
#   - This section defines the capabilities of fabric network. This is a new
#   concept as of v1.1.0 and should not be utilized in mixed networks with
#   v1.0.x peers and orderers.  Capabilities define features which must be
#   present in a fabric binary for that binary to safely participate in the
#   fabric network.  For instance, if a new MSP type is added, newer binaries
#   might recognize and validate the signatures from this type, while older
#   binaries without this support would be unable to validate those
#   transactions.  This could lead to different versions of the fabric binaries
#   having different world states.  Instead, defining a capability for a channel
#   informs those binaries without this capability that they must cease
#   processing transactions until they have been upgraded.  For v1.0.x if any
#   capabilities are defined (including a map with all capabilities turned off)
#   then the v1.0.x peer will deliberately crash.
#
################################################################################
Capabilities:
    # Channel capabilities apply to both the orderers and the peers and must be
    # supported by both.
    # Set the value of the capability to true to require it.
    Channel: &ChannelCapabilities
        # V2_0 capability ensures that orderers and peers behave according
        # to v2.0 channel capabilities. Orderers and peers from
        # prior releases would behave in an incompatible way, and are therefore
        # not able to participate in channels at v2.0 capability.
        # Prior to enabling V2.0 channel capabilities, ensure that all
        # orderers and peers on a channel are at v2.0.0 or later.
        V2_0: true

    # Orderer capabilities apply only to the orderers, and may be safely
    # used with prior release peers.
    # Set the value of the capability to true to require it.
    Orderer: &OrdererCapabilities
        # V2_0 orderer capability ensures that orderers behave according
        # to v2.0 orderer capabilities. Orderers from
        # prior releases would behave in an incompatible way, and are therefore
        # not able to participate in channels at v2.0 orderer capability.
        # Prior to enabling V2.0 orderer capabilities, ensure that all
        # orderers on channel are at v2.0.0 or later.
        V2_0: true

    # Application capabilities apply only to the peer network, and may be safely
    # used with prior release orderers.
    # Set the value of the capability to true to require it.
    Application: &ApplicationCapabilities
        # V2_0 application capability ensures that peers behave according
        # to v2.0 application capabilities. Peers from
        # prior releases would behave in an incompatible way, and are therefore
        # not able to participate in channels at v2.0 application capability.
        # Prior to enabling V2.0 application capabilities, ensure that all
        # peers on channel are at v2.0.0 or later.
        V2_0: true

################################################################################
#
#   SECTION: Application
#
#   - This section defines the values to encode into a config transaction or
#   genesis block for application related parameters
#
################################################################################
Application: &ApplicationDefaults

    # Organizations is the list of orgs which are defined as participants on
    # the application side of the network
    Organizations:

    # Policies defines the set of policies at this level of the config tree
    # For Application policies, their canonical path is
    #   /Channel/Application/<PolicyName>
    Policies:
        Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
        Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
        Admins:
            Type: ImplicitMeta
            Rule: "MAJORITY Admins"
        LifecycleEndorsement:
            Type: ImplicitMeta
            Rule: "MAJORITY Endorsement"
        Endorsement:
            Type: ImplicitMeta
            Rule: "MAJORITY Endorsement"

    Capabilities:
        <<: *ApplicationCapabilities
################################################################################
#
#   SECTION: Orderer
#
#   - This section defines the values to encode into a config transaction or
#   genesis block for orderer related parameters
#
################################################################################
Orderer: &OrdererDefaults

    # Orderer Type: The orderer implementation to start
    OrdererType: etcdraft

    # Addresses used to be the list of orderer addresses that clients and peers
    # could connect to.  However, this does not allow clients to associate orderer
    # addresses and orderer organizations which can be useful for things such
    # as TLS validation.  The preferred way to specify orderer addresses is now
    # to include the OrdererEndpoints item in your org definition
    Addresses:
        - orderer.example.com:7050

    EtcdRaft:
        Consenters:
        - Host: orderer.example.com
          Port: 7050
          ClientTLSCert: ../organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
          ServerTLSCert: ../organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt

    # Batch Timeout: The amount of time to wait before creating a batch
    BatchTimeout: 2s

    # Batch Size: Controls the number of messages batched into a block
    BatchSize:

        # Max Message Count: The maximum number of messages to permit in a batch
        MaxMessageCount: 10

        # Absolute Max Bytes: The absolute maximum number of bytes allowed for
        # the serialized messages in a batch.
        AbsoluteMaxBytes: 99 MB

        # Preferred Max Bytes: The preferred maximum number of bytes allowed for
        # the serialized messages in a batch. A message larger than the preferred
        # max bytes will result in a batch larger than preferred max bytes.
        PreferredMaxBytes: 512 KB

    # Organizations is the list of orgs which are defined as participants on
    # the orderer side of the network
    Organizations:

    # Policies defines the set of policies at this level of the config tree
    # For Orderer policies, their canonical path is
    #   /Channel/Orderer/<PolicyName>
    Policies:
        Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
        Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
        Admins:
            Type: ImplicitMeta
            Rule: "MAJORITY Admins"
        # BlockValidation specifies what signatures must be included in the block
        # from the orderer for the peer to validate it.
        BlockValidation:
            Type: ImplicitMeta
            Rule: "ANY Writers"

################################################################################
#
#   CHANNEL
#
#   This section defines the values to encode into a config transaction or
#   genesis block for channel related parameters.
#
################################################################################
Channel: &ChannelDefaults
    # Policies defines the set of policies at this level of the config tree
    # For Channel policies, their canonical path is
    #   /Channel/<PolicyName>
    Policies:
        # Who may invoke the 'Deliver' API
        Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
        # Who may invoke the 'Broadcast' API
        Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
        # By default, who may modify elements at this config level
        Admins:
            Type: ImplicitMeta
            Rule: "MAJORITY Admins"

    # Capabilities describes the channel level capabilities, see the
    # dedicated Capabilities section elsewhere in this file for a full
    # description
    Capabilities:
        <<: *ChannelCapabilities

################################################################################
#
#   Profile
#
#   - Different configuration profiles may be encoded here to be specified
#   as parameters to the configtxgen tool
#
################################################################################
Profiles:

    OrgsOrdererGenesis:
        <<: *ChannelDefaults
        Orderer:
            <<: *OrdererDefaults
            Organizations:
                - *OrdererOrg
            Capabilities:
                <<: *OrdererCapabilities
        Consortiums:
            SampleConsortium:
                Organizations:
                    - *Org1
                    - *Org2
                    - *Org3
                    - *Org4
    OrgsChannel:
        Consortium: SampleConsortium
        <<: *ChannelDefaults
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org1
                - *Org2
                - *Org3
                - *Org4
            Capabilities:
                <<: *ApplicationCapabilities

</code>```

This is my deployCC.sh script which I am using for installing the chaincode. I am actually using the command ./network.sh deployCC command.

```<code>#!/bin/bash

source scripts/utils.sh

CHANNEL_NAME=${1:-"mychannel"}
CC_NAME=${2}
CC_SRC_PATH=${3}
CC_SRC_LANGUAGE=${4}
CC_VERSION=${5:-"1.0"}
CC_SEQUENCE=${6:-"1"}
CC_INIT_FCN=${7:-"NA"}
CC_END_POLICY=${8:-"NA"}
CC_COLL_CONFIG=${9:-"NA"}
DELAY=${10:-"3"}
MAX_RETRY=${11:-"5"}
VERBOSE=${12:-"false"}

println "executing with the following"
println "- CHANNEL_NAME: ${C_GREEN}${CHANNEL_NAME}${C_RESET}"
println "- CC_NAME: ${C_GREEN}${CC_NAME}${C_RESET}"
println "- CC_SRC_PATH: ${C_GREEN}${CC_SRC_PATH}${C_RESET}"
println "- CC_SRC_LANGUAGE: ${C_GREEN}${CC_SRC_LANGUAGE}${C_RESET}"
println "- CC_VERSION: ${C_GREEN}${CC_VERSION}${C_RESET}"
println "- CC_SEQUENCE: ${C_GREEN}${CC_SEQUENCE}${C_RESET}"
println "- CC_END_POLICY: ${C_GREEN}${CC_END_POLICY}${C_RESET}"
println "- CC_COLL_CONFIG: ${C_GREEN}${CC_COLL_CONFIG}${C_RESET}"
println "- CC_INIT_FCN: ${C_GREEN}${CC_INIT_FCN}${C_RESET}"
println "- DELAY: ${C_GREEN}${DELAY}${C_RESET}"
println "- MAX_RETRY: ${C_GREEN}${MAX_RETRY}${C_RESET}"
println "- VERBOSE: ${C_GREEN}${VERBOSE}${C_RESET}"

FABRIC_CFG_PATH=$PWD/../config/

#User has not provided a name
if [ -z "$CC_NAME" ] || [ "$CC_NAME" = "NA" ]; then
  fatalln "No chaincode name was provided. Valid call example: ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go"

# User has not provided a path
elif [ -z "$CC_SRC_PATH" ] || [ "$CC_SRC_PATH" = "NA" ]; then
  fatalln "No chaincode path was provided. Valid call example: ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go"

# User has not provided a language
elif [ -z "$CC_SRC_LANGUAGE" ] || [ "$CC_SRC_LANGUAGE" = "NA" ]; then
  fatalln "No chaincode language was provided. Valid call example: ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go"

## Make sure that the path to the chaincode exists
elif [ ! -d "$CC_SRC_PATH" ]; then
  fatalln "Path to chaincode does not exist. Please provide different path."
fi

CC_SRC_LANGUAGE=$(echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:])

# do some language specific preparation to the chaincode before packaging
if [ "$CC_SRC_LANGUAGE" = "go" ]; then
  CC_RUNTIME_LANGUAGE=golang

  infoln "Vendoring Go dependencies at $CC_SRC_PATH"
  pushd $CC_SRC_PATH
  GO111MODULE=on go mod vendor
  popd
  successln "Finished vendoring Go dependencies"

elif [ "$CC_SRC_LANGUAGE" = "java" ]; then
  CC_RUNTIME_LANGUAGE=java

  infoln "Compiling Java code..."
  pushd $CC_SRC_PATH
  ./gradlew installDist
  popd
  successln "Finished compiling Java code"
  CC_SRC_PATH=$CC_SRC_PATH/build/install/$CC_NAME

elif [ "$CC_SRC_LANGUAGE" = "javascript" ]; then
  CC_RUNTIME_LANGUAGE=node

elif [ "$CC_SRC_LANGUAGE" = "typescript" ]; then
  CC_RUNTIME_LANGUAGE=node

  infoln "Compiling TypeScript code into JavaScript..."
  pushd $CC_SRC_PATH
  npm install
  npm run build
  popd
  successln "Finished compiling TypeScript code into JavaScript"

else
  fatalln "The chaincode language ${CC_SRC_LANGUAGE} is not supported by this script. Supported chaincode languages are: go, java, javascript, and typescript"
  exit 1
fi

INIT_REQUIRED="--init-required"
# check if the init fcn should be called
if [ "$CC_INIT_FCN" = "NA" ]; then
  INIT_REQUIRED=""
fi

if [ "$CC_END_POLICY" = "NA" ]; then
  CC_END_POLICY=""
else
  CC_END_POLICY="--signature-policy $CC_END_POLICY"
fi

if [ "$CC_COLL_CONFIG" = "NA" ]; then
  CC_COLL_CONFIG=""
else
  CC_COLL_CONFIG="--collections-config $CC_COLL_CONFIG"
fi

# import utils
. scripts/envVar.sh

packageChaincode() {
  set -x
  peer lifecycle chaincode package ${CC_NAME}.tar.gz --path ${CC_SRC_PATH} --lang ${CC_RUNTIME_LANGUAGE} --label ${CC_NAME}_${CC_VERSION} >&log.txt
  res=$?
  { set +x; } 2>/dev/null
  cat log.txt
  verifyResult $res "Chaincode packaging has failed"
  successln "Chaincode is packaged"
}

# installChaincode PEER ORG
installChaincode() {
  ORG=$1
  PEER=$2
  setGlobals $ORG $PEER
  set -x
  peer lifecycle chaincode install ${CC_NAME}.tar.gz >&log.txt
  res=$?
  { set +x; } 2>/dev/null
  cat log.txt
  verifyResult $res "Chaincode installation on peer${PEER}.org${ORG} has failed"
  successln "Chaincode is installed on peer${PEER}.org${ORG}"
}

# queryInstalled PEER ORG
queryInstalled() {
  ORG=$1
  PEER=$2
  setGlobals $ORG $PEER
  set -x
  peer lifecycle chaincode queryinstalled >&log.txt
  res=$?
  { set +x; } 2>/dev/null
  cat log.txt
  PACKAGE_ID=$(sed -n "/${CC_NAME}_${CC_VERSION}/{s/^Package ID: //; s/, Label:.*$//; p;}" log.txt)
  verifyResult $res "Query installed on peer${PEER}.org${ORG} has failed"
  successln "Query installed successful on peer${PEER}.org${ORG} on channel"
}

# approveForMyOrg VERSION PEER ORG
approveForMyOrg() {
  ORG=$1
  PEER=$2
  setGlobals $ORG $PEER
  set -x
  peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name ${CC_NAME} --version ${CC_VERSION} --package-id ${PACKAGE_ID} --sequence ${CC_SEQUENCE} ${INIT_REQUIRED} ${CC_END_POLICY} ${CC_COLL_CONFIG} >&log.txt
  res=$?
  { set +x; } 2>/dev/null
  cat log.txt
  verifyResult $res "Chaincode definition approved on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' failed"
  successln "Chaincode definition approved on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'"
}

# checkCommitReadiness VERSION PEER ORG
checkCommitReadiness() {
  ORG=$1
  PEER=$2
  shift 1
  setGlobals $ORG $PEER
  infoln "Checking the commit readiness of the chaincode definition on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'..."
  local rc=1
  local COUNTER=1
  # continue to poll
  # we either get a successful response, or reach MAX RETRY
  while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ]; do
    sleep $DELAY
    infoln "Attempting to check the commit readiness of the chaincode definition on peer${PEER}.org${ORG}, Retry after $DELAY seconds."
    set -x
    peer lifecycle chaincode checkcommitreadiness --channelID $CHANNEL_NAME --name ${CC_NAME} --version ${CC_VERSION} --sequence ${CC_SEQUENCE} ${INIT_REQUIRED} ${CC_END_POLICY} ${CC_COLL_CONFIG} --output json >&log.txt
    res=$?
    { set +x; } 2>/dev/null
    let rc=0
    for var in "$@"; do
      grep "$var" log.txt &>/dev/null || let rc=1
    done
    COUNTER=$(expr $COUNTER + 1)
  done
  cat log.txt
  if test $rc -eq 0; then
    infoln "Checking the commit readiness of the chaincode definition successful on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'"
  else
    fatalln "After $MAX_RETRY attempts, Check commit readiness result on peer${PEER}.org${ORG} is INVALID!"
  fi
}

# commitChaincodeDefinition VERSION PEER ORG (PEER ORG)...
commitChaincodeDefinition() {
  parsePeerConnectionParameters $@
  res=$?
  verifyResult $res "Invoke transaction failed on channel '$CHANNEL_NAME' due to uneven number of peer and org parameters "

  # while 'peer chaincode' command can get the orderer endpoint from the
  # peer (if join was successful), let's supply it directly as we know
  # it using the "-o" option
  set -x
  peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name ${CC_NAME} $PEER_CONN_PARMS --version ${CC_VERSION} --sequence ${CC_SEQUENCE} ${INIT_REQUIRED} ${CC_END_POLICY} ${CC_COLL_CONFIG} >&log.txt
  res=$?
  { set +x; } 2>/dev/null
  cat log.txt
  verifyResult $res "Chaincode definition commit failed on ${PEER} on channel '$CHANNEL_NAME' failed"
  successln "Chaincode definition committed on channel '$CHANNEL_NAME'"
}

# queryCommitted ORG
queryCommitted() {
  ORG=$1
  PEER=$2
  setGlobals $ORG $PEER
  EXPECTED_RESULT="Version: ${CC_VERSION}, Sequence: ${CC_SEQUENCE}, Endorsement Plugin: escc, Validation Plugin: vscc"
  infoln "Querying chaincode definition on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'..."
  local rc=1
  local COUNTER=1
  # continue to poll
  # we either get a successful response, or reach MAX RETRY
  while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ]; do
    sleep $DELAY
    infoln "Attempting to Query committed status on peer${PEER}.org${ORG}, Retry after $DELAY seconds."
    set -x
    peer lifecycle chaincode querycommitted --channelID $CHANNEL_NAME --name ${CC_NAME} >&log.txt
    res=$?
    { set +x; } 2>/dev/null
    test $res -eq 0 && VALUE=$(cat log.txt | grep -o '^Version: '$CC_VERSION', Sequence: [0-9]*, Endorsement Plugin: escc, Validation Plugin: vscc')
    test "$VALUE" = "$EXPECTED_RESULT" && let rc=0
    COUNTER=$(expr $COUNTER + 1)
  done
  cat log.txt
  if test $rc -eq 0; then
    successln "Query chaincode definition successful on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'"
  else
    fatalln "After $MAX_RETRY attempts, Query chaincode definition result on peer${PEER}.org${ORG} is INVALID!"
  fi
}

chaincodeInvokeInit() {
  parsePeerConnectionParameters $@
  res=$?
  verifyResult $res "Invoke transaction failed on channel '$CHANNEL_NAME' due to uneven number of peer and org parameters "

  # while 'peer chaincode' command can get the orderer endpoint from the
  # peer (if join was successful), let's supply it directly as we know
  # it using the "-o" option
  set -x
  fcn_call='{"function":"'${CC_INIT_FCN}'","Args":[]}'
  infoln "invoke fcn call:${fcn_call}"
  peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile $ORDERER_CA -C $CHANNEL_NAME -n ${CC_NAME} $PEER_CONN_PARMS --isInit -c ${fcn_call} >&log.txt
  res=$?
  { set +x; } 2>/dev/null
  cat log.txt
  verifyResult $res "Invoke execution on $PEERS failed "
  successln "Invoke transaction successful on $PEERS on channel '$CHANNEL_NAME'"
}

chaincodeQuery() {
  ORG=$1
  PEER=$2
  setGlobals $ORG $PEER
  infoln "Querying on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'..."
  local rc=1
  local COUNTER=1
  # continue to poll
  # we either get a successful response, or reach MAX RETRY
  while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ]; do
    sleep $DELAY
    infoln "Attempting to Query peer0.org${ORG}, Retry after $DELAY seconds."
    set -x
    peer chaincode query -C $CHANNEL_NAME -n ${CC_NAME} -c '{"Args":["queryAllAssets"]}' >&log.txt
    res=$?
    { set +x; } 2>/dev/null
    let rc=$res
    COUNTER=$(expr $COUNTER + 1)
  done
  cat log.txt
  if test $rc -eq 0; then
    successln "Query successful on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'"
  else
    fatalln "After $MAX_RETRY attempts, Query result on peer${PEER}.org${ORG} is INVALID!"
  fi
}

## package the chaincode
packageChaincode

## Install chaincode on peer0.org1 and peer0.org2
infoln "Installing chaincode on peer0.org1..."
installChaincode 1 0
infoln "Installing chaincode on peer1.org1..."
installChaincode 1 1
infoln "Install chaincode on peer0.org2..."
installChaincode 2 0
infoln "Install chaincode on peer1.org2..."
installChaincode 2 1
infoln "Install chaincode on peer0.org3..."
installChaincode 3 0
infoln "Install chaincode on peer1.org3..."
installChaincode 3 1
infoln "Install chaincode on peer0.org4..."
installChaincode 4 0
infoln "Install chaincode on peer1.org4..."
installChaincode 4 1

## query whether the chaincode is installed
queryInstalled 1 0

## approve the definition for org1
approveForMyOrg 1 0
approveForMyOrg 1 1

## check whether the chaincode definition is ready to be committed
## expect org1 to have approved and org2 not to
checkCommitReadiness 1 1

## now approve also for org2
approveForMyOrg 2 0
approveForMyOrg 2 1

## check whether the chaincode definition is ready to be committed
## expect them both to have approved
checkCommitReadiness 2 1

## now approve also for org3
approveForMyOrg 3 0
approveForMyOrg 3 1

## check whether the chaincode definition is ready to be committed
## expect them both to have approved
checkCommitReadiness 3 1

## now approve also for org4
approveForMyOrg 4 0
approveForMyOrg 4 1

## check whether the chaincode definition is ready to be committed
## expect them both to have approved
checkCommitReadiness 4 1

## now that we know for sure both orgs have approved, commit the definition
commitChaincodeDefinition 1 2 3 4

## query on both orgs to see that the definition committed successfully
queryCommitted 1 0
queryCommitted 1 1
queryCommitted 2 0
queryCommitted 2 1
queryCommitted 3 0
queryCommitted 3 1
queryCommitted 4 0
queryCommitted 4 1

## Invoke the chaincode - this does require that the chaincode have the 'initLedger'
## method defined
if [ "$CC_INIT_FCN" = "NA" ]; then
  infoln "Chaincode initialization is not required"
else
  chaincodeInvokeInit 1 2 3 4
fi

exit 0

</code>```

答:
It looks like you are attempting to approve the chaincode more than once for each organisation, which is unnecessary and probably why you're hitting the MVCC_READ_CONFLICT error (the error you get when a transaction reads a key which has been updated by another transaction).

From the Fabric chaincode lifecycle documentation...

Each channel member that wants to use the chaincode needs to approve a
chaincode definition for their organization. This approval needs to be
submitted to the ordering service, after which it is distributed to
all peers. This approval needs to be submitted by your Organization
Administrator. After the approval transaction has been successfully
submitted, the approved definition is stored in a collection that is
available to all the peers of your organization. As a result you only
need to approve a chaincode for your organization once, even if you
have multiple peers.

Title: Chaincode Deployment Failed on Peer1

Body:
Hi I am getting the following Error when Installing the chaincode. I have tried everything but still no clue what is happening.Please help me on this.

2022-01-28 12:36:06.833 IST 0001 INFO [chaincodeCmd] ClientWait -> txid [cd68692e297f8bee9e6dbfdd726467901875683e411c1fb8b1580b7ab358b952] committed with status (MVCC_READ_CONFLICT) at localhost:8051
Error: transaction invalidated with status (MVCC_READ_CONFLICT)
Chaincode definition approved on peer1.org1 on channel 'mychannel' failed
Deploying chaincode failed

This is configtx-

Organizations:
    - &OrdererOrg
        Name: OrdererOrg
        ID: OrdererMSP
        MSPDir: ../organizations/ordererOrganizations/example.com/msp

        Policies:
            Readers:
                Type: Signature
                Rule: "OR('OrdererMSP.member')"
            Writers:
                Type: Signature
                Rule: "OR('OrdererMSP.member')"
            Admins:
                Type: Signature
                Rule: "OR('OrdererMSP.admin')"

        OrdererEndpoints:
            - orderer.example.com:7050

    - &Org1
        Name: Org1MSP
        ID: Org1MSP
        MSPDir: ../organizations/peerOrganizations/org1.example.com/msp

        Policies:
            Readers:
                Type: Signature
                Rule: "OR('Org1MSP.admin', 'Org1MSP.peer', 'Org1MSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('Org1MSP.admin', 'Org1MSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('Org1MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org1MSP.peer')"

    - &Org2
        Name: Org2MSP
        ID: Org2MSP

        MSPDir: ../organizations/peerOrganizations/org2.example.com/msp

        Policies:
            Readers:
                Type: Signature
                Rule: "OR('Org2MSP.admin', 'Org2MSP.peer', 'Org2MSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('Org2MSP.admin', 'Org2MSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('Org2MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org2MSP.peer')"

    - &Org3
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: Org3MSP

        # ID to load the MSP definition as
        ID: Org3MSP

        MSPDir: ../organizations/peerOrganizations/org3.example.com/msp

        # Policies defines the set of policies at this level of the config tree
        # For organization policies, their canonical path is usually
        #   /Channel/<Application|Orderer>/<OrgName>/<PolicyName>
        Policies:
            Readers:
                Type: Signature
                Rule: "OR('Org3MSP.admin', 'Org3MSP.peer', 'Org3MSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('Org3MSP.admin', 'Org3MSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('Org3MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org3MSP.peer')"

    - &Org4
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: Org4MSP

        # ID to load the MSP definition as
        ID: Org4MSP

        MSPDir: ../organizations/peerOrganizations/org4.example.com/msp

        # Policies defines the set of policies at this level of the config tree
        # For organization policies, their canonical path is usually
        #   /Channel/<Application|Orderer>/<OrgName>/<PolicyName>
        Policies:
            Readers:
                Type: Signature
                Rule: "OR('Org4MSP.admin', 'Org4MSP.peer', 'Org4MSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('Org4MSP.admin', 'Org4MSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('Org4MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org4MSP.peer')"

################################################################################
#
#   SECTION: Capabilities
#
#   - This section defines the capabilities of fabric network. This is a new
#   concept as of v1.1.0 and should not be utilized in mixed networks with
#   v1.0.x peers and orderers.  Capabilities define features which must be
#   present in a fabric binary for that binary to safely participate in the
#   fabric network.  For instance, if a new MSP type is added, newer binaries
#   might recognize and validate the signatures from this type, while older
#   binaries without this support would be unable to validate those
#   transactions.  This could lead to different versions of the fabric binaries
#   having different world states.  Instead, defining a capability for a channel
#   informs those binaries without this capability that they must cease
#   processing transactions until they have been upgraded.  For v1.0.x if any
#   capabilities are defined (including a map with all capabilities turned off)
#   then the v1.0.x peer will deliberately crash.
#
################################################################################
Capabilities:
    # Channel capabilities apply to both the orderers and the peers and must be
    # supported by both.
    # Set the value of the capability to true to require it.
    Channel: &ChannelCapabilities
        # V2_0 capability ensures that orderers and peers behave according
        # to v2.0 channel capabilities. Orderers and peers from
        # prior releases would behave in an incompatible way, and are therefore
        # not able to participate in channels at v2.0 capability.
        # Prior to enabling V2.0 channel capabilities, ensure that all
        # orderers and peers on a channel are at v2.0.0 or later.
        V2_0: true

    # Orderer capabilities apply only to the orderers, and may be safely
    # used with prior release peers.
    # Set the value of the capability to true to require it.
    Orderer: &OrdererCapabilities
        # V2_0 orderer capability ensures that orderers behave according
        # to v2.0 orderer capabilities. Orderers from
        # prior releases would behave in an incompatible way, and are therefore
        # not able to participate in channels at v2.0 orderer capability.
        # Prior to enabling V2.0 orderer capabilities, ensure that all
        # orderers on channel are at v2.0.0 or later.
        V2_0: true

    # Application capabilities apply only to the peer network, and may be safely
    # used with prior release orderers.
    # Set the value of the capability to true to require it.
    Application: &ApplicationCapabilities
        # V2_0 application capability ensures that peers behave according
        # to v2.0 application capabilities. Peers from
        # prior releases would behave in an incompatible way, and are therefore
        # not able to participate in channels at v2.0 application capability.
        # Prior to enabling V2.0 application capabilities, ensure that all
        # peers on channel are at v2.0.0 or later.
        V2_0: true

################################################################################
#
#   SECTION: Application
#
#   - This section defines the values to encode into a config transaction or
#   genesis block for application related parameters
#
################################################################################
Application: &ApplicationDefaults

    # Organizations is the list of orgs which are defined as participants on
    # the application side of the network
    Organizations:

    # Policies defines the set of policies at this level of the config tree
    # For Application policies, their canonical path is
    #   /Channel/Application/<PolicyName>
    Policies:
        Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
        Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
        Admins:
            Type: ImplicitMeta
            Rule: "MAJORITY Admins"
        LifecycleEndorsement:
            Type: ImplicitMeta
            Rule: "MAJORITY Endorsement"
        Endorsement:
            Type: ImplicitMeta
            Rule: "MAJORITY Endorsement"

    Capabilities:
        <<: *ApplicationCapabilities
################################################################################
#
#   SECTION: Orderer
#
#   - This section defines the values to encode into a config transaction or
#   genesis block for orderer related parameters
#
################################################################################
Orderer: &OrdererDefaults

    # Orderer Type: The orderer implementation to start
    OrdererType: etcdraft

    # Addresses used to be the list of orderer addresses that clients and peers
    # could connect to.  However, this does not allow clients to associate orderer
    # addresses and orderer organizations which can be useful for things such
    # as TLS validation.  The preferred way to specify orderer addresses is now
    # to include the OrdererEndpoints item in your org definition
    Addresses:
        - orderer.example.com:7050

    EtcdRaft:
        Consenters:
        - Host: orderer.example.com
          Port: 7050
          ClientTLSCert: ../organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
          ServerTLSCert: ../organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt

    # Batch Timeout: The amount of time to wait before creating a batch
    BatchTimeout: 2s

    # Batch Size: Controls the number of messages batched into a block
    BatchSize:

        # Max Message Count: The maximum number of messages to permit in a batch
        MaxMessageCount: 10

        # Absolute Max Bytes: The absolute maximum number of bytes allowed for
        # the serialized messages in a batch.
        AbsoluteMaxBytes: 99 MB

        # Preferred Max Bytes: The preferred maximum number of bytes allowed for
        # the serialized messages in a batch. A message larger than the preferred
        # max bytes will result in a batch larger than preferred max bytes.
        PreferredMaxBytes: 512 KB

    # Organizations is the list of orgs which are defined as participants on
    # the orderer side of the network
    Organizations:

    # Policies defines the set of policies at this level of the config tree
    # For Orderer policies, their canonical path is
    #   /Channel/Orderer/<PolicyName>
    Policies:
        Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
        Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
        Admins:
            Type: ImplicitMeta
            Rule: "MAJORITY Admins"
        # BlockValidation specifies what signatures must be included in the block
        # from the orderer for the peer to validate it.
        BlockValidation:
            Type: ImplicitMeta
            Rule: "ANY Writers"

################################################################################
#
#   CHANNEL
#
#   This section defines the values to encode into a config transaction or
#   genesis block for channel related parameters.
#
################################################################################
Channel: &ChannelDefaults
    # Policies defines the set of policies at this level of the config tree
    # For Channel policies, their canonical path is
    #   /Channel/<PolicyName>
    Policies:
        # Who may invoke the 'Deliver' API
        Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
        # Who may invoke the 'Broadcast' API
        Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
        # By default, who may modify elements at this config level
        Admins:
            Type: ImplicitMeta
            Rule: "MAJORITY Admins"

    # Capabilities describes the channel level capabilities, see the
    # dedicated Capabilities section elsewhere in this file for a full
    # description
    Capabilities:
        <<: *ChannelCapabilities

################################################################################
#
#   Profile
#
#   - Different configuration profiles may be encoded here to be specified
#   as parameters to the configtxgen tool
#
################################################################################
Profiles:

    OrgsOrdererGenesis:
        <<: *ChannelDefaults
        Orderer:
            <<: *OrdererDefaults
            Organizations:
                - *OrdererOrg
            Capabilities:
                <<: *OrdererCapabilities
        Consortiums:
            SampleConsortium:
                Organizations:
                    - *Org1
                    - *Org2
                    - *Org3
                    - *Org4
    OrgsChannel:
        Consortium: SampleConsortium
        <<: *ChannelDefaults
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org1
                - *Org2
                - *Org3
                - *Org4
            Capabilities:
                <<: *ApplicationCapabilities

This is my deployCC.sh script which I am using for installing the chaincode. I am actually using the command ./network.sh deployCC command.

#!/bin/bash

source scripts/utils.sh

CHANNEL_NAME=${1:-"mychannel"}
CC_NAME=${2}
CC_SRC_PATH=${3}
CC_SRC_LANGUAGE=${4}
CC_VERSION=${5:-"1.0"}
CC_SEQUENCE=${6:-"1"}
CC_INIT_FCN=${7:-"NA"}
CC_END_POLICY=${8:-"NA"}
CC_COLL_CONFIG=${9:-"NA"}
DELAY=${10:-"3"}
MAX_RETRY=${11:-"5"}
VERBOSE=${12:-"false"}

println "executing with the following"
println "- CHANNEL_NAME: ${C_GREEN}${CHANNEL_NAME}${C_RESET}"
println "- CC_NAME: ${C_GREEN}${CC_NAME}${C_RESET}"
println "- CC_SRC_PATH: ${C_GREEN}${CC_SRC_PATH}${C_RESET}"
println "- CC_SRC_LANGUAGE: ${C_GREEN}${CC_SRC_LANGUAGE}${C_RESET}"
println "- CC_VERSION: ${C_GREEN}${CC_VERSION}${C_RESET}"
println "- CC_SEQUENCE: ${C_GREEN}${CC_SEQUENCE}${C_RESET}"
println "- CC_END_POLICY: ${C_GREEN}${CC_END_POLICY}${C_RESET}"
println "- CC_COLL_CONFIG: ${C_GREEN}${CC_COLL_CONFIG}${C_RESET}"
println "- CC_INIT_FCN: ${C_GREEN}${CC_INIT_FCN}${C_RESET}"
println "- DELAY: ${C_GREEN}${DELAY}${C_RESET}"
println "- MAX_RETRY: ${C_GREEN}${MAX_RETRY}${C_RESET}"
println "- VERBOSE: ${C_GREEN}${VERBOSE}${C_RESET}"

FABRIC_CFG_PATH=$PWD/../config/

#User has not provided a name
if [ -z "$CC_NAME" ] || [ "$CC_NAME" = "NA" ]; then
  fatalln "No chaincode name was provided. Valid call example: ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go"

# User has not provided a path
elif [ -z "$CC_SRC_PATH" ] || [ "$CC_SRC_PATH" = "NA" ]; then
  fatalln "No chaincode path was provided. Valid call example: ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go"

# User has not provided a language
elif [ -z "$CC_SRC_LANGUAGE" ] || [ "$CC_SRC_LANGUAGE" = "NA" ]; then
  fatalln "No chaincode language was provided. Valid call example: ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go"

## Make sure that the path to the chaincode exists
elif [ ! -d "$CC_SRC_PATH" ]; then
  fatalln "Path to chaincode does not exist. Please provide different path."
fi

CC_SRC_LANGUAGE=$(echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:])

# do some language specific preparation to the chaincode before packaging
if [ "$CC_SRC_LANGUAGE" = "go" ]; then
  CC_RUNTIME_LANGUAGE=golang

  infoln "Vendoring Go dependencies at $CC_SRC_PATH"
  pushd $CC_SRC_PATH
  GO111MODULE=on go mod vendor
  popd
  successln "Finished vendoring Go dependencies"

elif [ "$CC_SRC_LANGUAGE" = "java" ]; then
  CC_RUNTIME_LANGUAGE=java

  infoln "Compiling Java code..."
  pushd $CC_SRC_PATH
  ./gradlew installDist
  popd
  successln "Finished compiling Java code"
  CC_SRC_PATH=$CC_SRC_PATH/build/install/$CC_NAME

elif [ "$CC_SRC_LANGUAGE" = "javascript" ]; then
  CC_RUNTIME_LANGUAGE=node

elif [ "$CC_SRC_LANGUAGE" = "typescript" ]; then
  CC_RUNTIME_LANGUAGE=node

  infoln "Compiling TypeScript code into JavaScript..."
  pushd $CC_SRC_PATH
  npm install
  npm run build
  popd
  successln "Finished compiling TypeScript code into JavaScript"

else
  fatalln "The chaincode language ${CC_SRC_LANGUAGE} is not supported by this script. Supported chaincode languages are: go, java, javascript, and typescript"
  exit 1
fi

INIT_REQUIRED="--init-required"
# check if the init fcn should be called
if [ "$CC_INIT_FCN" = "NA" ]; then
  INIT_REQUIRED=""
fi

if [ "$CC_END_POLICY" = "NA" ]; then
  CC_END_POLICY=""
else
  CC_END_POLICY="--signature-policy $CC_END_POLICY"
fi

if [ "$CC_COLL_CONFIG" = "NA" ]; then
  CC_COLL_CONFIG=""
else
  CC_COLL_CONFIG="--collections-config $CC_COLL_CONFIG"
fi

# import utils
. scripts/envVar.sh

packageChaincode() {
  set -x
  peer lifecycle chaincode package ${CC_NAME}.tar.gz --path ${CC_SRC_PATH} --lang ${CC_RUNTIME_LANGUAGE} --label ${CC_NAME}_${CC_VERSION} >&log.txt
  res=$?
  { set +x; } 2>/dev/null
  cat log.txt
  verifyResult $res "Chaincode packaging has failed"
  successln "Chaincode is packaged"
}

# installChaincode PEER ORG
installChaincode() {
  ORG=$1
  PEER=$2
  setGlobals $ORG $PEER
  set -x
  peer lifecycle chaincode install ${CC_NAME}.tar.gz >&log.txt
  res=$?
  { set +x; } 2>/dev/null
  cat log.txt
  verifyResult $res "Chaincode installation on peer${PEER}.org${ORG} has failed"
  successln "Chaincode is installed on peer${PEER}.org${ORG}"
}

# queryInstalled PEER ORG
queryInstalled() {
  ORG=$1
  PEER=$2
  setGlobals $ORG $PEER
  set -x
  peer lifecycle chaincode queryinstalled >&log.txt
  res=$?
  { set +x; } 2>/dev/null
  cat log.txt
  PACKAGE_ID=$(sed -n "/${CC_NAME}_${CC_VERSION}/{s/^Package ID: //; s/, Label:.*$//; p;}" log.txt)
  verifyResult $res "Query installed on peer${PEER}.org${ORG} has failed"
  successln "Query installed successful on peer${PEER}.org${ORG} on channel"
}

# approveForMyOrg VERSION PEER ORG
approveForMyOrg() {
  ORG=$1
  PEER=$2
  setGlobals $ORG $PEER
  set -x
  peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name ${CC_NAME} --version ${CC_VERSION} --package-id ${PACKAGE_ID} --sequence ${CC_SEQUENCE} ${INIT_REQUIRED} ${CC_END_POLICY} ${CC_COLL_CONFIG} >&log.txt
  res=$?
  { set +x; } 2>/dev/null
  cat log.txt
  verifyResult $res "Chaincode definition approved on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' failed"
  successln "Chaincode definition approved on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'"
}

# checkCommitReadiness VERSION PEER ORG
checkCommitReadiness() {
  ORG=$1
  PEER=$2
  shift 1
  setGlobals $ORG $PEER
  infoln "Checking the commit readiness of the chaincode definition on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'..."
  local rc=1
  local COUNTER=1
  # continue to poll
  # we either get a successful response, or reach MAX RETRY
  while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ]; do
    sleep $DELAY
    infoln "Attempting to check the commit readiness of the chaincode definition on peer${PEER}.org${ORG}, Retry after $DELAY seconds."
    set -x
    peer lifecycle chaincode checkcommitreadiness --channelID $CHANNEL_NAME --name ${CC_NAME} --version ${CC_VERSION} --sequence ${CC_SEQUENCE} ${INIT_REQUIRED} ${CC_END_POLICY} ${CC_COLL_CONFIG} --output json >&log.txt
    res=$?
    { set +x; } 2>/dev/null
    let rc=0
    for var in "$@"; do
      grep "$var" log.txt &>/dev/null || let rc=1
    done
    COUNTER=$(expr $COUNTER + 1)
  done
  cat log.txt
  if test $rc -eq 0; then
    infoln "Checking the commit readiness of the chaincode definition successful on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'"
  else
    fatalln "After $MAX_RETRY attempts, Check commit readiness result on peer${PEER}.org${ORG} is INVALID!"
  fi
}

# commitChaincodeDefinition VERSION PEER ORG (PEER ORG)...
commitChaincodeDefinition() {
  parsePeerConnectionParameters $@
  res=$?
  verifyResult $res "Invoke transaction failed on channel '$CHANNEL_NAME' due to uneven number of peer and org parameters "

  # while 'peer chaincode' command can get the orderer endpoint from the
  # peer (if join was successful), let's supply it directly as we know
  # it using the "-o" option
  set -x
  peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name ${CC_NAME} $PEER_CONN_PARMS --version ${CC_VERSION} --sequence ${CC_SEQUENCE} ${INIT_REQUIRED} ${CC_END_POLICY} ${CC_COLL_CONFIG} >&log.txt
  res=$?
  { set +x; } 2>/dev/null
  cat log.txt
  verifyResult $res "Chaincode definition commit failed on ${PEER} on channel '$CHANNEL_NAME' failed"
  successln "Chaincode definition committed on channel '$CHANNEL_NAME'"
}

# queryCommitted ORG
queryCommitted() {
  ORG=$1
  PEER=$2
  setGlobals $ORG $PEER
  EXPECTED_RESULT="Version: ${CC_VERSION}, Sequence: ${CC_SEQUENCE}, Endorsement Plugin: escc, Validation Plugin: vscc"
  infoln "Querying chaincode definition on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'..."
  local rc=1
  local COUNTER=1
  # continue to poll
  # we either get a successful response, or reach MAX RETRY
  while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ]; do
    sleep $DELAY
    infoln "Attempting to Query committed status on peer${PEER}.org${ORG}, Retry after $DELAY seconds."
    set -x
    peer lifecycle chaincode querycommitted --channelID $CHANNEL_NAME --name ${CC_NAME} >&log.txt
    res=$?
    { set +x; } 2>/dev/null
    test $res -eq 0 && VALUE=$(cat log.txt | grep -o '^Version: '$CC_VERSION', Sequence: [0-9]*, Endorsement Plugin: escc, Validation Plugin: vscc')
    test "$VALUE" = "$EXPECTED_RESULT" && let rc=0
    COUNTER=$(expr $COUNTER + 1)
  done
  cat log.txt
  if test $rc -eq 0; then
    successln "Query chaincode definition successful on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'"
  else
    fatalln "After $MAX_RETRY attempts, Query chaincode definition result on peer${PEER}.org${ORG} is INVALID!"
  fi
}

chaincodeInvokeInit() {
  parsePeerConnectionParameters $@
  res=$?
  verifyResult $res "Invoke transaction failed on channel '$CHANNEL_NAME' due to uneven number of peer and org parameters "

  # while 'peer chaincode' command can get the orderer endpoint from the
  # peer (if join was successful), let's supply it directly as we know
  # it using the "-o" option
  set -x
  fcn_call='{"function":"'${CC_INIT_FCN}'","Args":[]}'
  infoln "invoke fcn call:${fcn_call}"
  peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile $ORDERER_CA -C $CHANNEL_NAME -n ${CC_NAME} $PEER_CONN_PARMS --isInit -c ${fcn_call} >&log.txt
  res=$?
  { set +x; } 2>/dev/null
  cat log.txt
  verifyResult $res "Invoke execution on $PEERS failed "
  successln "Invoke transaction successful on $PEERS on channel '$CHANNEL_NAME'"
}

chaincodeQuery() {
  ORG=$1
  PEER=$2
  setGlobals $ORG $PEER
  infoln "Querying on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'..."
  local rc=1
  local COUNTER=1
  # continue to poll
  # we either get a successful response, or reach MAX RETRY
  while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ]; do
    sleep $DELAY
    infoln "Attempting to Query peer0.org${ORG}, Retry after $DELAY seconds."
    set -x
    peer chaincode query -C $CHANNEL_NAME -n ${CC_NAME} -c '{"Args":["queryAllAssets"]}' >&log.txt
    res=$?
    { set +x; } 2>/dev/null
    let rc=$res
    COUNTER=$(expr $COUNTER + 1)
  done
  cat log.txt
  if test $rc -eq 0; then
    successln "Query successful on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'"
  else
    fatalln "After $MAX_RETRY attempts, Query result on peer${PEER}.org${ORG} is INVALID!"
  fi
}

## package the chaincode
packageChaincode

## Install chaincode on peer0.org1 and peer0.org2
infoln "Installing chaincode on peer0.org1..."
installChaincode 1 0
infoln "Installing chaincode on peer1.org1..."
installChaincode 1 1
infoln "Install chaincode on peer0.org2..."
installChaincode 2 0
infoln "Install chaincode on peer1.org2..."
installChaincode 2 1
infoln "Install chaincode on peer0.org3..."
installChaincode 3 0
infoln "Install chaincode on peer1.org3..."
installChaincode 3 1
infoln "Install chaincode on peer0.org4..."
installChaincode 4 0
infoln "Install chaincode on peer1.org4..."
installChaincode 4 1

## query whether the chaincode is installed
queryInstalled 1 0

## approve the definition for org1
approveForMyOrg 1 0
approveForMyOrg 1 1

## check whether the chaincode definition is ready to be committed
## expect org1 to have approved and org2 not to
checkCommitReadiness 1 1

## now approve also for org2
approveForMyOrg 2 0
approveForMyOrg 2 1

## check whether the chaincode definition is ready to be committed
## expect them both to have approved
checkCommitReadiness 2 1

## now approve also for org3
approveForMyOrg 3 0
approveForMyOrg 3 1

## check whether the chaincode definition is ready to be committed
## expect them both to have approved
checkCommitReadiness 3 1

## now approve also for org4
approveForMyOrg 4 0
approveForMyOrg 4 1

## check whether the chaincode definition is ready to be committed
## expect them both to have approved
checkCommitReadiness 4 1

## now that we know for sure both orgs have approved, commit the definition
commitChaincodeDefinition 1 2 3 4

## query on both orgs to see that the definition committed successfully
queryCommitted 1 0
queryCommitted 1 1
queryCommitted 2 0
queryCommitted 2 1
queryCommitted 3 0
queryCommitted 3 1
queryCommitted 4 0
queryCommitted 4 1

## Invoke the chaincode - this does require that the chaincode have the 'initLedger'
## method defined
if [ "$CC_INIT_FCN" = "NA" ]; then
  infoln "Chaincode initialization is not required"
else
  chaincodeInvokeInit 1 2 3 4
fi

exit 0


问:
Facebook connect -
I  want to use face book connect on my website. And i cant find proper Documentation on face book to use it. Can you help me out with it ?</p>

答: This website gives you a start up for facebookconnect.</p>

ContentLicense: CC BY-SA 2.5

Title: Facebook connect -

ContentLicense: CC BY-SA 3.0


问:
javax.net.ssl.SSLException: Connection reset on few request out of the total
We have a service that is sending POST request once every second to one of our mircoservices.
The sent request is to the same URL each time it is sent.

The code class TrackTask that sends request is using org.apache.http.impl.client.CloseableHttpClient and creating a POST request using org.apache.http.client.methods.HttpPost.

Out of 3600 request we send in one hour we get SSLException on few requests but it is very random.
Can be on 2 requests out of 3600 and can be 8.

The exception we got:

```<code>javax.net.ssl.SSLException: Connection reset
        at sun.security.ssl.Alert.createSSLException(Alert.java:127) ~[na:1.8.0_312]
        at sun.security.ssl.TransportContext.fatal(TransportContext.java:324) ~[na:1.8.0_312]
        at sun.security.ssl.TransportContext.fatal(TransportContext.java:267) ~[na:1.8.0_312]
        at sun.security.ssl.TransportContext.fatal(TransportContext.java:262) ~[na:1.8.0_312]
        at sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1563) ~[na:1.8.0_312]
        at sun.security.ssl.SSLSocketImpl.access$400(SSLSocketImpl.java:73) ~[na:1.8.0_312]
        at sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:973) ~[na:1.8.0_312]
        at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:280) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:157) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at com.cooladata.da.TrackTask.sendTrack(TrackTask.java:62) [da-qa-1.0-SNAPSHOT.jar:na]
        at com.cooladata.da.TrackTask.startListening(TrackTask.java:108) [da-qa-1.0-SNAPSHOT.jar:na]
        at com.cooladata.da.TrackTask.run(TrackTask.java:120) [da-qa-1.0-SNAPSHOT.jar:na]
        at java.lang.Thread.run(Thread.java:748) [na:1.8.0_312]
        Suppressed: java.net.SocketException: Broken pipe (Write failed)
                at java.net.SocketOutputStream.socketWrite0(Native Method) ~[na:1.8.0_312]
                at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111) ~[na:1.8.0_312]
                at java.net.SocketOutputStream.write(SocketOutputStream.java:155) ~[na:1.8.0_312]
                at sun.security.ssl.SSLSocketOutputRecord.encodeAlert(SSLSocketOutputRecord.java:81) ~[na:1.8.0_312]
                at sun.security.ssl.TransportContext.fatal(TransportContext.java:355) ~[na:1.8.0_312]
                ... 26 common frames omitted
Caused by: java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:210) ~[na:1.8.0_312]
        at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[na:1.8.0_312]
        at sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:464) ~[na:1.8.0_312]
        at sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(SSLSocketInputRecord.java:68) ~[na:1.8.0_312]
        at sun.security.ssl.SSLSocketImpl.readApplicationRecord(SSLSocketImpl.java:1341) ~[na:1.8.0_312]
        at sun.security.ssl.SSLSocketImpl.access$300(SSLSocketImpl.java:73) ~[na:1.8.0_312]
        at sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:957) ~[na:1.8.0_312]
        ... 21 common frames omitted
</code>```

We use to have none or almost no such exceptions at all.

Can anyone help us understand what is the reason for such random exception and how we can resolve it ?

答:
Fixed thanks to the post of Spring Boot random "SSLException: Connection reset" in Kubernetes with JDK11

Once I configured the httpclient to NO REUSE connection it worked and we dont get anymore SSLExceptions:

```<code>httpClient = HttpClients.custom().setDefaultRequestConfig(config)
        .setConnectionReuseStrategy(NoConnectionReuseStrategy.INSTANCE)
        .setConnectionManager(poolingConnManager)
        .build();
</code>```

Body:
We have a service that is sending POST request once every second to one of our mircoservices.
The sent request is to the same URL each time it is sent.

The code class TrackTask that sends request is using org.apache.http.impl.client.CloseableHttpClient and creating a POST request using org.apache.http.client.methods.HttpPost.

Out of 3600 request we send in one hour we get SSLException on few requests but it is very random.
Can be on 2 requests out of 3600 and can be 8.

The exception we got:

javax.net.ssl.SSLException: Connection reset
        at sun.security.ssl.Alert.createSSLException(Alert.java:127) ~[na:1.8.0_312]
        at sun.security.ssl.TransportContext.fatal(TransportContext.java:324) ~[na:1.8.0_312]
        at sun.security.ssl.TransportContext.fatal(TransportContext.java:267) ~[na:1.8.0_312]
        at sun.security.ssl.TransportContext.fatal(TransportContext.java:262) ~[na:1.8.0_312]
        at sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1563) ~[na:1.8.0_312]
        at sun.security.ssl.SSLSocketImpl.access$400(SSLSocketImpl.java:73) ~[na:1.8.0_312]
        at sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:973) ~[na:1.8.0_312]
        at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:280) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:157) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108) ~[da-qa-1.0-SNAPSHOT.jar:na]
        at com.cooladata.da.TrackTask.sendTrack(TrackTask.java:62) [da-qa-1.0-SNAPSHOT.jar:na]
        at com.cooladata.da.TrackTask.startListening(TrackTask.java:108) [da-qa-1.0-SNAPSHOT.jar:na]
        at com.cooladata.da.TrackTask.run(TrackTask.java:120) [da-qa-1.0-SNAPSHOT.jar:na]
        at java.lang.Thread.run(Thread.java:748) [na:1.8.0_312]
        Suppressed: java.net.SocketException: Broken pipe (Write failed)
                at java.net.SocketOutputStream.socketWrite0(Native Method) ~[na:1.8.0_312]
                at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111) ~[na:1.8.0_312]
                at java.net.SocketOutputStream.write(SocketOutputStream.java:155) ~[na:1.8.0_312]
                at sun.security.ssl.SSLSocketOutputRecord.encodeAlert(SSLSocketOutputRecord.java:81) ~[na:1.8.0_312]
                at sun.security.ssl.TransportContext.fatal(TransportContext.java:355) ~[na:1.8.0_312]
                ... 26 common frames omitted
Caused by: java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:210) ~[na:1.8.0_312]
        at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[na:1.8.0_312]
        at sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:464) ~[na:1.8.0_312]
        at sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(SSLSocketInputRecord.java:68) ~[na:1.8.0_312]
        at sun.security.ssl.SSLSocketImpl.readApplicationRecord(SSLSocketImpl.java:1341) ~[na:1.8.0_312]
        at sun.security.ssl.SSLSocketImpl.access$300(SSLSocketImpl.java:73) ~[na:1.8.0_312]
        at sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:957) ~[na:1.8.0_312]
        ... 21 common frames omitted

We use to have none or almost no such exceptions at all.

Can anyone help us understand what is the reason for such random exception and how we can resolve it ?

Body:
Fixed thanks to the post of Spring Boot random "SSLException: Connection reset" in Kubernetes with JDK11

Once I configured the httpclient to NO REUSE connection it worked and we dont get anymore SSLExceptions:

httpClient = HttpClients.custom().setDefaultRequestConfig(config)
        .setConnectionReuseStrategy(NoConnectionReuseStrategy.INSTANCE)
        .setConnectionManager(poolingConnManager)
        .build();


问:
Azure Active Directory - Scopes - Localisation
When you're defining a new scope (under "Expose an api") in an app registration, then you can fill out the scope's title and description.

Is there any way to localise / translate this? So that end-users can see the consent request in their own language?

I can't seem to find anything on the subject in the microsoft docs.

Thank you!

答: Adding localized names and descriptions is not currently possible. It's something that's planned, but no timeline to share at the moment.</p>


问:
RangeError: WebAssembly.instantiate(): Out of memory: wasm memory
I am getting this error while starting my node js app in my cpanel.

```<code>RangeError: WebAssembly.instantiate(): Out of memory: wasm memory
at internal/deps/cjs-module-lexer/dist/lexer.js:1:33573
</code>```

but while i am developing in localhost, everything works just fine.

Here is my output log,

```<code>0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/opt/alt/alt-nodejs14/root/usr/bin/node',
1 verbose cli   '/opt/alt/alt-nodejs14/root/usr/bin/npm',
1 verbose cli   'run-script',
1 verbose cli   'start',
1 verbose cli   '--'
1 verbose cli ]
2 info using npm@6.14.13
3 info using node@v14.17.3
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle thewebapp@1.0.0~prestart: thewebapp@1.0.0
6 info lifecycle thewebapp@1.0.0~start: thewebapp@1.0.0
7 verbose lifecycle thewebapp@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle thewebapp@1.0.0~start: PATH: /opt/alt/alt-nodejs14/root/usr/lib/node_modules/npm/node_modules.bundled/npm-lifecycle/node-gyp-bin:/home/proudpos/backend/node_modules/.bin:/opt/alt/alt-nodejs14/root/usr/bin:/home/proudpos/nodevenv/backend/14/bin:/opt/alt/alt-nodejs14/root/usr/bin:/home/proudpos/nodevenv/backend/14/lib/bin/:/usr/local/jdk/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin:/opt/bin
9 verbose lifecycle thewebapp@1.0.0~start: CWD: /home/proudpos/backend
10 silly lifecycle thewebapp@1.0.0~start: Args: [ '-c', 'node server.js' ]
11 silly lifecycle thewebapp@1.0.0~start: Returned: code: 1  signal: null
12 info lifecycle thewebapp@1.0.0~start: Failed to exec start script
13 verbose stack Error: thewebapp@1.0.0 start: `node server.js`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/opt/alt/alt-nodejs14/root/usr/lib/node_modules/npm/node_modules.bundled/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:375:28)
13 verbose stack     at ChildProcess.<anonymous> (/opt/alt/alt-nodejs14/root/usr/lib/node_modules/npm/node_modules.bundled/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:375:28)
13 verbose stack     at maybeClose (internal/child_process.js:1055:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid thewebapp@1.0.0
15 verbose cwd /home/proudpos/backend
16 verbose Linux 3.10.0-962.3.2.lve1.5.60.el7.x86_64
17 verbose argv "/opt/alt/alt-nodejs14/root/usr/bin/node" "/opt/alt/alt-nodejs14/root/usr/bin/npm" "run-script" "start" "--"
18 verbose node v14.17.3
19 verbose npm  v6.14.13
20 error code ELIFECYCLE
21 error errno 1
22 error thewebapp@1.0.0 start: `node server.js`
22 error Exit status 1
23 error Failed at the thewebapp@1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
</code>```

I searched but could not found any answer.
need some help with this.

答: Just ssh and run npm run dev and it will work.In my case I did not reupload the code.</p>

Body:
I am getting this error while starting my node js app in my cpanel.

RangeError: WebAssembly.instantiate(): Out of memory: wasm memory
at internal/deps/cjs-module-lexer/dist/lexer.js:1:33573

but while i am developing in localhost, everything works just fine.

Here is my output log,

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/opt/alt/alt-nodejs14/root/usr/bin/node',
1 verbose cli   '/opt/alt/alt-nodejs14/root/usr/bin/npm',
1 verbose cli   'run-script',
1 verbose cli   'start',
1 verbose cli   '--'
1 verbose cli ]
2 info using npm@6.14.13
3 info using node@v14.17.3
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle thewebapp@1.0.0~prestart: thewebapp@1.0.0
6 info lifecycle thewebapp@1.0.0~start: thewebapp@1.0.0
7 verbose lifecycle thewebapp@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle thewebapp@1.0.0~start: PATH: /opt/alt/alt-nodejs14/root/usr/lib/node_modules/npm/node_modules.bundled/npm-lifecycle/node-gyp-bin:/home/proudpos/backend/node_modules/.bin:/opt/alt/alt-nodejs14/root/usr/bin:/home/proudpos/nodevenv/backend/14/bin:/opt/alt/alt-nodejs14/root/usr/bin:/home/proudpos/nodevenv/backend/14/lib/bin/:/usr/local/jdk/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin:/opt/bin
9 verbose lifecycle thewebapp@1.0.0~start: CWD: /home/proudpos/backend
10 silly lifecycle thewebapp@1.0.0~start: Args: [ '-c', 'node server.js' ]
11 silly lifecycle thewebapp@1.0.0~start: Returned: code: 1  signal: null
12 info lifecycle thewebapp@1.0.0~start: Failed to exec start script
13 verbose stack Error: thewebapp@1.0.0 start: `node server.js`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/opt/alt/alt-nodejs14/root/usr/lib/node_modules/npm/node_modules.bundled/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:375:28)
13 verbose stack     at ChildProcess.<anonymous> (/opt/alt/alt-nodejs14/root/usr/lib/node_modules/npm/node_modules.bundled/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:375:28)
13 verbose stack     at maybeClose (internal/child_process.js:1055:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid thewebapp@1.0.0
15 verbose cwd /home/proudpos/backend
16 verbose Linux 3.10.0-962.3.2.lve1.5.60.el7.x86_64
17 verbose argv "/opt/alt/alt-nodejs14/root/usr/bin/node" "/opt/alt/alt-nodejs14/root/usr/bin/npm" "run-script" "start" "--"
18 verbose node v14.17.3
19 verbose npm  v6.14.13
20 error code ELIFECYCLE
21 error errno 1
22 error thewebapp@1.0.0 start: `node server.js`
22 error Exit status 1
23 error Failed at the thewebapp@1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

I searched but could not found any answer.
need some help with this.


问:
WARNING:tensorflow:Your input ran out of data; interrupting training
Python
Dataset problem in last train step
WARNING:tensorflow:Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least steps_per_epoch * epochs batches (in this case, 2000 batches). You may need to use the repeat() function when building your dataset.
from keras.preprocessing.image import ImageDataGenerator

```<code>train_datagen = ImageDataGenerator(rescale=1./255,
                                   shear_range=0.2,
                                   zoom_range=0.2,
                                   horizontal_flip=True)

test_datagen = ImageDataGenerator(rescale=1./255)

training_set = train_datagen.flow_from_directory('dataset/training_set',
                                                 target_size=(64, 64),
                                                 batch_size=32,
                                                 class_mode='binary')

test_set = test_datagen.flow_from_directory('dataset/test_set',
                                            target_size=(64, 64),
                                            batch_size=32,
                                            class_mode='binary')

classifer.fit_generator(training_set,
                        steps_per_epoch=(8000),
                        epochs=25,`enter code here`
                        validation_data=test_set,
                        validation_steps=2000)
</code>```

答:
you have code

```<code>classifer.fit_generator(training_set,
                        steps_per_epoch=(8000),
                        epochs=25,`enter code here`
                        validation_data=test_set,
                        validation_steps=2000)
</code>```

the entry 'enter code here' doesn't belong in model.fit_generator. Also .fit_generator is depreciated just use .fit. You do not need to specify steps_per_epoch or validation_steps in .fit. It will internally calculate them. However if you wish to specify them then use code

```<code>steps_per_epoch= total images in trainset//batch_size
</code>```

For the validation steps you can use a similar code, however if you want to go through the validation set exactly once per epoch then use this code

```<code>length=total number of images in test set
valid_batch_size=sorted([int(length/n) for n in range(1,length+1) if length % n ==0 and length/n<=80],reverse=True)[0]
validation_steps=int(length/test_batch_size)
</code>```

use valid_batch_size as the batch size in your test_datagen. What the code does is determine the batch size and steps such that
valid_batch_size * validation_steps = total number of images in test set.

Body:
Python
Dataset problem in last train step
WARNING:tensorflow:Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least steps_per_epoch * epochs batches (in this case, 2000 batches). You may need to use the repeat() function when building your dataset.
from keras.preprocessing.image import ImageDataGenerator

train_datagen = ImageDataGenerator(rescale=1./255,
                                   shear_range=0.2,
                                   zoom_range=0.2,
                                   horizontal_flip=True)

test_datagen = ImageDataGenerator(rescale=1./255)

training_set = train_datagen.flow_from_directory('dataset/training_set',
                                                 target_size=(64, 64),
                                                 batch_size=32,
                                                 class_mode='binary')

test_set = test_datagen.flow_from_directory('dataset/test_set',
                                            target_size=(64, 64),
                                            batch_size=32,
                                            class_mode='binary')

classifer.fit_generator(training_set,
                        steps_per_epoch=(8000),
                        epochs=25,`enter code here`
                        validation_data=test_set,
                        validation_steps=2000)

Body:
you have code

classifer.fit_generator(training_set,
                        steps_per_epoch=(8000),
                        epochs=25,`enter code here`
                        validation_data=test_set,
                        validation_steps=2000)

the entry 'enter code here' doesn't belong in model.fit_generator. Also .fit_generator is depreciated just use .fit. You do not need to specify steps_per_epoch or validation_steps in .fit. It will internally calculate them. However if you wish to specify them then use code

steps_per_epoch= total images in trainset//batch_size

For the validation steps you can use a similar code, however if you want to go through the validation set exactly once per epoch then use this code

length=total number of images in test set
valid_batch_size=sorted([int(length/n) for n in range(1,length+1) if length % n ==0 and length/n<=80],reverse=True)[0]
validation_steps=int(length/test_batch_size)

use valid_batch_size as the batch size in your test_datagen. What the code does is determine the batch size and steps such that
valid_batch_size * validation_steps = total number of images in test set.


问:
Getting Microsoft Team Meetings Using the Graph API
I am getting all Teams meetings using the Microsoft Graph API but I don't find any API on the Microsoft documentation website someone suggests me any link how did I get all previous meetings using team API</p>

答: You can use List events to get a list of event objects in the user's mailbox. The list contains single instance meetings and series masters.</p>


问:
Calling a nested function JavaScript
I am new to JavaScript. I have this piece of code. I need to print the following:

```<code>//counter() should return the next number.
//counter.set(value) should set the counter to value.
//counter.decrease() should decrease the counter by 1

function makeCounter() {
  let count = 0;

  function counter() {
    return count++;
  }

  counter.decrease = function () {
    return count--;
  };

  counter.set = function (value) {
    return count = value;
  };
}
</code>```

How can I call the 3 nested functions outside?

答:
You just have to return your counter.

function makeCounter() {
  let count = 0;

  function counter() {
    return count++;
  }

  counter.decrease = function () {
    return count--;
  };

  counter.set = function (value) {
    return count = value;
  };

  return counter;
}

const myCounter = makeCounter();

console.log(myCounter()); // 0
console.log(myCounter()); // 1
console.log(myCounter.set(42)); // 42
console.log(myCounter()); // 42 (*see why next)
console.log(myCounter.decrease()); // 43 (*see why next)
console.log(myCounter()); // 42```

Be carefull with notation count++ because it returns count then add 1. If you want to add 1 then return the new value of count, please write ++count.

Title: Calling a nested function JavaScript

Body:
I am new to JavaScript. I have this piece of code. I need to print the following:

//counter() should return the next number.
//counter.set(value) should set the counter to value.
//counter.decrease() should decrease the counter by 1

function makeCounter() {
  let count = 0;

  function counter() {
    return count++;
  }

  counter.decrease = function () {
    return count--;
  };

  counter.set = function (value) {
    return count = value;
  };
}

How can I call the 3 nested functions outside?

Body:
You just have to return your counter.

function makeCounter() {
  let count = 0;

  function counter() {
    return count++;
  }

  counter.decrease = function () {
    return count--;
  };

  counter.set = function (value) {
    return count = value;
  };

  return counter;
}

const myCounter = makeCounter();

console.log(myCounter()); // 0
console.log(myCounter()); // 1
console.log(myCounter.set(42)); // 42
console.log(myCounter()); // 42 (*see why next)
console.log(myCounter.decrease()); // 43 (*see why next)
console.log(myCounter()); // 42

Be carefull with notation count++ because it returns count then add 1. If you want to add 1 then return the new value of count, please write ++count.


问:
My Loop In JS Won't Work For A Mystifying Reason
Ive been studing JS for 2 month and my teacher gave this assignment so as usuall i solve it but here i tried many hours but i can't Although that i'm pretty sure my answer logically is right but i don't know why the name repeated just one time

The Required Output is :

String [Osama], [Mohamed], [Ali], [Ibrahim] => Done !

Important Note : The [] isn't an array

/*
  Function Arrow Challenges
*/

// [1] One Statement In Function
// [2] Convert To Arrow Function
// [3] Print The Output [Arguments May Change]

let names = function (...name) {
  for (let i = 0; i < name.length; i++) {
    return `String [${name[i]}], => Done ~`
}};

console.log(names("Osama", "Mohamed", "Ali", "Ibrahim"));
// String [Osama], [Mohamed], [Ali], [Ibrahim] => Done !```

Question : How could i solve this ? with a logical explain to the answer

答:
try to add String [${name[i]}], => Done ~ into variable , for example

```<code>var S+=`String [${name[i]}], => Done ~`
return S;
</code>```

/*
  Function Arrow Challenges
*/

// [1] One Statement In Function
// [2] Convert To Arrow Function
// [3] Print The Output [Arguments May Change]

let names = function (...name) {
  for (let i = 0; i < name.length; i++) {
    return `String [${name[i]}], => Done ~`
}};

console.log(names("Osama", "Mohamed", "Ali", "Ibrahim"));
// String [Osama], [Mohamed], [Ali], [Ibrahim] => Done !```

Body:
Ive been studing JS for 2 month and my teacher gave this assignment so as usuall i solve it but here i tried many hours but i can't Although that i'm pretty sure my answer logically is right but i don't know why the name repeated just one time

The Required Output is :

String [Osama], [Mohamed], [Ali], [Ibrahim] => Done !

Important Note : The [] isn't an array

/*
  Function Arrow Challenges
*/

// [1] One Statement In Function
// [2] Convert To Arrow Function
// [3] Print The Output [Arguments May Change]

let names = function (...name) {
  for (let i = 0; i < name.length; i++) {
    return `String [${name[i]}], => Done ~`
}};

console.log(names("Osama", "Mohamed", "Ali", "Ibrahim"));
// String [Osama], [Mohamed], [Ali], [Ibrahim] => Done !

Question : How could i solve this ? with a logical explain to the answer

Body:
try to add String [${name[i]}], => Done ~ into variable , for example

var S+=`String [${name[i]}], => Done ~`
return S;

/*
  Function Arrow Challenges
*/

// [1] One Statement In Function
// [2] Convert To Arrow Function
// [3] Print The Output [Arguments May Change]

let names = function (...name) {
  for (let i = 0; i < name.length; i++) {
    return `String [${name[i]}], => Done ~`
}};

console.log(names("Osama", "Mohamed", "Ali", "Ibrahim"));
// String [Osama], [Mohamed], [Ali], [Ibrahim] => Done !


问:
iPhone LINE-IN audio recording Possible?
Can we record audio from direct line-in input with iPhone?</p>

答: The only way is to create your own accessory using the dock connector and then to use the API's provided!</p>


问:
Call second coroutine function without blocking the first function
I have coroutine function that return the result of a network call.

I want my function to return the result and call another function in a parallel way without waiting for the second function to finish.

This is my function

```<code>suspend fun getResult() : NetworkResponse<ApiResult, ApiError>?
{
    return withContext(Dispatchers.IO) {

        val localData : LocalData? = _localDataSource?.await()

        val result : NetworkResponse<ApiResult, ApiError>? = fetchFromNetwork(_localDataSource, localData).getOrNull()

        doAdditionalWork(localData, result)

        result
    }
}
</code>```

And this is my second function

```<code>private suspend fun doAdditionalWork(localData : LocalData?, apiResponse : NetworkResponse<ApiResult, ApiError>?)
{
    delay(5000)
    //...
}
</code>```

I just want the function 1 to return the result without waiting for the function 2. So how can i do it?

答:
Try to wrap it in launch or async block:

```<code>launch { doAdditionalWork(localData, result) }
</code>```

It will run the function in parallel.

Other suggestion is to run doAdditionalWork after getResult() is executed:

```<code>someScope.launch {
    val resultPair = getResult()
    launch { doAdditionalWork(resultPair.second, resultPair.first) } // if you want to run it in parallel with the below code if any.

    // if there are no other code to run in parallel, you can just call `doAdditionalWork(...)` without `launch` block

    // ... some other code if any
}

suspend fun getResult() : Pair<NetworkResponse<ApiResult, ApiError>, LocalData?>
{
    return withContext(Dispatchers.IO) {

        val localData : LocalData? = _localDataSource?.await()

        val result : NetworkResponse<ApiResult, ApiError>? = fetchFromNetwork(_localDataSource, localData).getOrNull()

        Pair(result, localData)
    }
}
</code>```

Body:
I have coroutine function that return the result of a network call.

I want my function to return the result and call another function in a parallel way without waiting for the second function to finish.

This is my function

suspend fun getResult() : NetworkResponse<ApiResult, ApiError>?
{
    return withContext(Dispatchers.IO) {

        val localData : LocalData? = _localDataSource?.await()

        val result : NetworkResponse<ApiResult, ApiError>? = fetchFromNetwork(_localDataSource, localData).getOrNull()

        doAdditionalWork(localData, result)

        result
    }
}

And this is my second function

private suspend fun doAdditionalWork(localData : LocalData?, apiResponse : NetworkResponse<ApiResult, ApiError>?)
{
    delay(5000)
    //...
}

I just want the function 1 to return the result without waiting for the function 2. So how can i do it?

Body:
Try to wrap it in launch or async block:

launch { doAdditionalWork(localData, result) }

It will run the function in parallel.

Other suggestion is to run doAdditionalWork after getResult() is executed:

someScope.launch {
    val resultPair = getResult()
    launch { doAdditionalWork(resultPair.second, resultPair.first) } // if you want to run it in parallel with the below code if any.

    // if there are no other code to run in parallel, you can just call `doAdditionalWork(...)` without `launch` block

    // ... some other code if any
}

suspend fun getResult() : Pair<NetworkResponse<ApiResult, ApiError>, LocalData?>
{
    return withContext(Dispatchers.IO) {

        val localData : LocalData? = _localDataSource?.await()

        val result : NetworkResponse<ApiResult, ApiError>? = fetchFromNetwork(_localDataSource, localData).getOrNull()

        Pair(result, localData)
    }
}


问:
How to disable Inkwell image button in flutter
I would like to make the inkwell image button to be disabled. I can disable onTap event, but can't make gray like disabled button. I tried with adding this code

decoration: new BoxDecoration(color:Colors.grey.withOpacity(0.6)),
```
<p>But it doesn't work as I want.</p>
<p>My code:</p>
<pre class="lang-dart prettyprint-override"><code> child: Container(
              decoration:
                  new BoxDecoration(color: Colors.grey.withOpacity(0.6)),
              child: Material(
                //elevation: 4.0,
                clipBehavior: Clip.none,
                color: Colors.black,
                child: Stack(
                  alignment: Alignment.center,
                  fit: StackFit.passthrough,
                  children: [
                    Ink.image(
                      image: AssetImage(ihaveheard_imagepath),
                      fit: BoxFit.cover,
                      width: MediaQuery.of(context).size.width / 4 * 3,
                      height: MediaQuery.of(context).size.width / 6,
                      child: InkWell(onTap: () {}),
                    ),
                    Align(
                      alignment: Alignment.center,
                      child: Padding(
                        padding: EdgeInsets.all(8.0),
                        child: InkWell(
                          child: Text(
                            LocaleKeys.ihaveheard,
                            style: TextStyle(
                                fontSize:
                                    MediaQuery.of(context).size.width / 30,
                                color: Colors.white),
                          ).tr(),
                          onTap: () {
                            ihaveheard_imagepath =
                                "assets/images/greenbutton.png";

                            setState(() {});
                          },
                        ),
                      ),
                    )
                  ],
                ),
              ),
            ),
</code>```

答:
```<code>child:
 IgnorePointer(
              ignoring: disableBtn, //true or false

              child: Container(
                foregroundDecoration: disableBtn
                    ? BoxDecoration( //this can make disabled effect
                        color: Colors.grey,
                        backgroundBlendMode: BlendMode.lighten)
                    : null,
               child: ...

</code>```

Body:
I would like to make the inkwell image button to be disabled. I can disable onTap event, but can't make gray like disabled button. I tried with adding this code

decoration: new BoxDecoration(color:Colors.grey.withOpacity(0.6)),

But it doesn't work as I want.

My code:

 child: Container(
              decoration:
                  new BoxDecoration(color: Colors.grey.withOpacity(0.6)),
              child: Material(
                //elevation: 4.0,
                clipBehavior: Clip.none,
                color: Colors.black,
                child: Stack(
                  alignment: Alignment.center,
                  fit: StackFit.passthrough,
                  children: [
                    Ink.image(
                      image: AssetImage(ihaveheard_imagepath),
                      fit: BoxFit.cover,
                      width: MediaQuery.of(context).size.width / 4 * 3,
                      height: MediaQuery.of(context).size.width / 6,
                      child: InkWell(onTap: () {}),
                    ),
                    Align(
                      alignment: Alignment.center,
                      child: Padding(
                        padding: EdgeInsets.all(8.0),
                        child: InkWell(
                          child: Text(
                            LocaleKeys.ihaveheard,
                            style: TextStyle(
                                fontSize:
                                    MediaQuery.of(context).size.width / 30,
                                color: Colors.white),
                          ).tr(),
                          onTap: () {
                            ihaveheard_imagepath =
                                "assets/images/greenbutton.png";

                            setState(() {});
                          },
                        ),
                      ),
                    )
                  ],
                ),
              ),
            ),