Help Center> ServiceStage> FAQs> Application Development> How Do I Handle a Microservice Registry Failure (Java Chassis)?
Updated on 2023-07-14 GMT+08:00

How Do I Handle a Microservice Registry Failure (Java Chassis)?

When a microservice is successfully deployed, register it with the service center and the configuration center to enable the microservice discovery and governance capabilities. The microservice registry fails when any of the following conditions are met:

  • The AK/SK is not configured or is incorrect.
  • The address of the service center or configuration center is incorrect.
  • The network connection is faulty.
  • The domain name resolution fails.
  • The monitoring port is already occupied.

Fault Locating

  • If the following error message is displayed, the AK/SK information is incorrectly configured or carried in the request header.
    {"errorCode":"401002","errorMessage":"Request unauthorized","detail":"Invalid request, header is invalid, ak sk or project is empty."}
    Checking method:
    1. Check whether the project depends on the following authentication modules (indirect dependency is permitted, for example, the project depends on the cse-solution-service-engine):
      <groupId>com.huawei.paas.cse</groupId>
      <artifactId>foundation-auth</artifactId>
    2. Check whether AK/SK in the microservice.yaml file is correct. To obtain correct AK/SK, see Managing Access Keys.
      cse:
        credentials:
          accessKey: your access key
          secretKey: your secret key
          akskCustomCipher: default
  • If the following error message is displayed, the AK/SK information is incorrectly configured.
    {"errorCode":"401002","errorMessage":"Request unauthorized","detail":"Get service token from iam proxy failed,{\"error\":\"validate ak sk error\"}"}

    Checking method:

    Check whether AK/SK in the microservice.yaml file is correct. To obtain correct AK/SK, see Managing Access Keys.
    cse:
      credentials:
        accessKey: your access key
        secretKey: your secret key
        akskCustomCipher: default
  • If the following error message is displayed, the project information is incorrectly configured.
    {"errorCode":"401002","errorMessage":"Request unauthorized","detail":"Get service token from iam proxy failed,{\"error\":\"get project token from iam failed. error:http post failed, statuscode: 400\"}"}

    Checking method:

    Check whether the project information in the microservice.yaml file is correct. For details, see Viewing the Project Name.

    cse:
      credentials:
        accessKey: your access key
        secretKey: your secret key
        akskCustomCipher: default
        project: cn-north-1
  • If the following error message is displayed, there is insufficient quota to add a service instance.
    {"errorCode":"400100","errorMessage":"Not enough quota","detail":"no quota to create instance, ..."}

    Checking method:

    Log in to the public cloud and view the instance quota on the microservice engine page. If the quota is sufficient, check the service center address and region information configured in the code. Note that you need to check the instance quota of the region where the instance is located.

  • If the microservice fails to access the service center or configuration center, the following information is displayed. The microservice does not access the service center or configuration center. Therefore, no error code can be found in the service center or configuration center.
    Connection refused: no further information

    Checking method:

    1. Check whether IP addresses of the service center and configuration center in the microservice.yaml file are correct. If not, correct them.
      cse:
        service:                  //Information about the service center. The address field indicates the service center address.
          registry:
            address: https://cse.cn-north-1.myhuaweicloud.com
            instance:
              watch: false
        config:                   //Information about the configuration center. The address field indicates the configuration center address.
          client:
            serverUri: https://cse.cn-north-1.myhuaweicloud.com
            refreshMode: 1
            refresh_interval: 5000
    2. If IP addresses of the service center and configuration center are correct, run the following commands to check whether the network is normal.

      ping <servicecenter ip>

      ping <configurationcenter ip>

      If ping command execution is successful, the network connection is normal.

      If the address of the service center or configuration center is a domain name, change the address configured in the microservice.yaml file to the domain name. Then, run the ping command.

    3. If the network is normal, run the following command to obtain the IP address of the service center or configuration center.

      ping <domain name>

      If the following information is displayed, configure the obtained IP address and domain name in the local /etc/hosts file.

      10.153.78.18   cse.cn-north-1.myhuaweicloud.com
  • In addition, if a microservice port number is occupied, the microservice may fail to start. In this case, you can run the following command to check whether the service monitoring port is occupied.

    netstat -ano | findstr 8080

    If the port is occupied by another application, modify the microservice.yaml file and change the monitoring port to an unoccupied port.

    rest:
        address: 0.0.0.0:8087  //Microservice port. Ensure that the port number is unique.

Application Development FAQs

more