Starts in:
2 DAYS
9 HRS
22 MIN
2 SEC
Starts in:
2 D
9 H
22 M
2 S
Open Closed

An error occurred while generating the client proxy for microservice/angular #2824


User avatar
0
chenxm created

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: v5.2.0-RC.2
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace: [Invalid Module] Backend module "productService" does not exist in API definition.
  • Steps to reproduce the issue:" create new microservice solution and exec abp generate-proxy -t ng

9 Answer(s)
  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    Is the product service up and running when you run abp generate-proxy -t ng?

  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    Also, can you share your environment.ts file?

  • User Avatar
    0
    chenxm created

    Also, can you share your environment.ts file?

    ` import { Environment } from '@abp/ng.core';

    const baseUrl = 'http://localhost:4200';

    const oAuthConfig = { issuer: 'https://localhost:44322', redirectUri: baseUrl, clientId: 'PlatCloud_Angular', responseType: 'code', scope: 'offline_access openid profile email phone AccountService IdentityService AdministrationService SaasService ProductService', requireHttps: true, };

    export const environment = { production: false, application: { baseUrl, name: 'PlatCloud', }, oAuthConfig, apis: { default: { url: 'https://localhost:44325', rootNamespace: 'PlatCloud', }, AbpAccountPublic: { url: oAuthConfig.issuer, rootNamespace: 'AbpAccountPublic', }, ProductService: { url: 'https://localhost:44361', rootNamespace: 'PlatCloud', }, }, } as Environment;

    `

  • User Avatar
    0
    chenxm created

    Is the product service up and running when you run abp generate-proxy -t ng?

    yes, product service is running.

  • User Avatar
    0
    chenxm created

    Please try to use ABP suite to create a new microservice solution. This problem still exists in the latest version 5.2.0. I hope the team can solve this problem urgently,It has seriously affected our actual work. I can't start working.

  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    We have investigated this issue. We need make some improvements to apis configuration since all the services need to be redirected to web gateway. However when this is the case, abp generate-proxy -t ng doesn't work because web gateway doesn't have the api definitions (gateways do not depend on microservice HTTP.API layers) since we are not using dynamic proxy any longer.

    We'll try to decide on a subtle way to generate proxy with angular when using a gateway.

    export const environment = {
        production: false,
        application: {
            baseUrl,
            name: 'PlatCloud',
        },
        oAuthConfig,
        apis: {
            default: {
                url: 'https://localhost:44325',
                rootNamespace: 'PlatCloud',
            },
            AbpAccountPublic: {
                url: oAuthConfig.issuer,
                rootNamespace: 'AbpAccountPublic',
            },
            ProductService: {
                url: 'https://localhost:44361',
                rootNamespace: 'PlatCloud',
            },
        },
    } as Environment;
    

    When you defined ProductService with its own address, it should generate the related proxies with abp generate-proxy -t ng. I will try it on 5.2.0 and let you know.

  • User Avatar
    0
    chenxm created

    We have investigated this issue. We need make some improvements to apis configuration since all the services need to be redirected to web gateway. However when this is the case, abp generate-proxy -t ng doesn't work because web gateway doesn't have the api definitions (gateways do not depend on microservice HTTP.API layers) since we are not using dynamic proxy any longer.

    We'll try to decide on a subtle way to generate proxy with angular when using a gateway.

    export const environment = { 
        production: false, 
        application: { 
            baseUrl, 
            name: 'PlatCloud', 
        }, 
        oAuthConfig, 
        apis: { 
            default: { 
                url: 'https://localhost:44325', 
                rootNamespace: 'PlatCloud', 
            }, 
            AbpAccountPublic: { 
                url: oAuthConfig.issuer, 
                rootNamespace: 'AbpAccountPublic', 
            }, 
            ProductService: { 
                url: 'https://localhost:44361', 
                rootNamespace: 'PlatCloud', 
            }, 
        }, 
    } as Environment; 
    

    When you defined ProductService with its own address, it should generate the related proxies with abp generate-proxy -t ng. I will try it on 5.2.0 and let you know.

    Thank you very much. Unfortunately, I have failed on 5.2.0.

  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    We have reproduced this problem. As a workaround, you can set default api URL to productService in environment.ts when generating proxy like:

    export const environment = {
      ...
      apis: {
        default: {
          url: 'https://localhost:44361',
          rootNamespace: 'MyMicroApp',
        },
        AbpAccountPublic: {
          url: oAuthConfig.issuer,
          rootNamespace: 'AbpAccountPublic',
        },
        ProductService: {
          url: 'https://localhost:44325',
          rootNamespace: 'MyMicroApp',
        },
      },
    } as Environment;
    

    Note: Don't forget to revert back to web-gateway.

    I have refunded your question.

    Thank you for your report.

  • User Avatar
    0
    chenxm created

    We have reproduced this problem. As a workaround, you can set default api URL to productService in environment.ts when generating proxy like:

    export const environment = { 
      ... 
      apis: { 
        default: { 
          url: 'https://localhost:44361', 
          rootNamespace: 'MyMicroApp', 
        }, 
        AbpAccountPublic: { 
          url: oAuthConfig.issuer, 
          rootNamespace: 'AbpAccountPublic', 
        }, 
        ProductService: { 
          url: 'https://localhost:44325', 
          rootNamespace: 'MyMicroApp', 
        }, 
      }, 
    } as Environment; 
    

    Note: Don't forget to revert back to web-gateway.

    I have refunded your question.

    Thank you for your report.

    first, thank you for your solution,can solve my problem temporarily.

    step1: Modify the default service URL to the URL of a specific service step2: execute abp generate-proxy -t ng -m productService

    but, It is hoped that further improvements can be made to enhance the ability of ABP generate proxy, such as adding command parameters to specify the specific service address rather than modifying the configuration file, such as abp generate-proxy - t ng -m productservice --url https://localhost:44361,or better。

    In addition, I hope to have more perfect test coverage when releasing the new version.

    May it be better and more perfect. Thank you.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06