Open Closed

Unable to receive JWT to application API #8341


User avatar
0
Tony_Albutt created
  • ABP Framework version: v8.3.3
  • UI Type: MVC
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

Hi

I am unable to connect to my application API. I have 3 issues. 1 If I set the application method to [AllowAnonymous], I van use postman to get a token, and receive a response. When I debug the Application method, the system does not decode the Token, resulting in the CurrentUser = NULL I do decode the Tenant info. This may be some ware between ABP framework migration from V3 to 4 to 5 to 6 to 7 to 8.3.3

2 When I use the shell cmd : abp generate-proxy -t csharp -u https://localhost:44334/ my application breaks with the following error. System.StackOverflowException Looking for file /_/src/libraries/System.Private.CoreLib/src/System/Type.cs please select file. Exception message and full stack trace - added below

So I created a new test application and added one entity "ApiParameters". I then added a new copy of the module "Integration" into the application I added all the references and Dependencies. The new application has full access to the module can use all methods for all 12 entities. When I use the shell cmd : abp generate-proxy -t csharp -u https://localhost:44381/ only the "ApiParameters" proxies are added to the ClientProxies folder. This is the 3rd issue.

3 I am unable to generate client proxies for a module application "Integration", only the host "ApiParameters" proxy. Is there a missing parameter?

Please, are you able to assist?

Thanks and regards Tony


33 Answer(s)
  • User Avatar
    0
    Tony_Albutt created

    Cool, no problem. 🎉

    This is throwing an error.

    Busy tracing

  • User Avatar
    0
    Tony_Albutt created

    Yay, I had two issues.

    The stack overflow was been caused by a return type Syncfusion.XlsIO.IWorksheet If I paused the AddCustomTypesToModel method every 1800 passes, http garbage collection could handle it.

    The other parameter type causing the problem was a return type : MimeKit MimeMessage

    Thanks, I can now run the CMD abp generate-proxy -t csharp -u https://localhost:44334/ -m Integration --without-contracts

    When I call the endpoint

        Guid.TryParse(id, out Guid accountSegmentId);
        var result = await _accountSegmentsApiAppService.GetAsync(accountSegmentId);
    

    I am getting the following error

    2024-11-28 16:01:34.155 +02:00 [ERR] ---------- RemoteServiceErrorInfo ---------- { "code": null, "message": "An internal error occurred during your request!", "details": null, "data": {}, "validationErrors": null }

    2024-11-28 16:01:34.156 +02:00 [ERR] Could not get HttpClientProxyConfig for Integration.AccountSegments.IAccountSegmentsAppService. Volo.Abp.AbpException: Could not get HttpClientProxyConfig for Integration.AccountSegments.IAccountSegmentsAppService. at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync(ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase`1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments) at ClientProxies.Integration.AccountSegments.AccountSegmentClientProxy.GetAsync(Guid id) in F:\Outpost\src\Outpost.Application\ClientProxies\Integration\AccountSegments\AccountSegmentClientProxy.Generated.cs:line 35 at Outpost.Web.Pages.Testing.ItxTestModel.OnPostAsync() in F:\Outpost\src\Outpost.Web\Pages\Testing\ItxTest.cshtml.cs:line 91 at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.GenericTaskHandlerMethod.Convert[T](Object taskAsObject) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.GenericTaskHandlerMethod.Execute(Object receiver, Object[] arguments) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeHandlerMethodAsync() at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeNextPageFilterAsync()

    I have checked the following

    appsettings.json

    "RemoteServices": {
        "ITX_Home": {
          "BaseUrl": "https://localhost:44334/"
        }
      },
    

    OutpostApplicationModule

    [DependsOn(typeof(IntegrationApplicationModule))]
    [DependsOn(
        typeof(AbpHttpClientModule), 
        typeof(AbpVirtualFileSystemModule)
    )]
    public class OutpostApplicationModule : AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            // Prepare for static client proxy generation
            context.Services.AddStaticHttpClientProxies(
                typeof(OutpostApplicationModule).Assembly,
                remoteServiceConfigurationName:"ITX_Home"
            );
    
            // Include the generated app-generate-proxy.json in the virtual file system
            Configure<AbpVirtualFileSystemOptions>(options =>
            {
                options.FileSets.AddEmbedded<OutpostApplicationModule>();
            });
            Configure<AbpAutoMapperOptions>(options =>
            {
                options.AddMaps<OutpostApplicationModule>();
            });
        }
    }
    

    class OutpostWebModule

    //PreConfigureServices
    
            PreConfigure<AbpHttpClientBuilderOptions>(options =>
            {
                options.ProxyClientBuildActions.Add((remoteServiceName, clientBuilder) =>
                {
                    clientBuilder.AddTransientHttpErrorPolicy(
                        policyBuilder => policyBuilder.WaitAndRetryAsync(3, i => TimeSpan.FromSeconds(Math.Pow(2, i)))
                    );
                });
            });
           
    //ConfigureServices
           Configure<AbpHttpClientOptions>(options =>
           {
               options.HttpClientProxies.Add(typeof(ISubscriptionAppService), new HttpClientProxyConfig(typeof(ISubscriptionAppService), SaasHostRemoteServiceConsts.RemoteServiceName));
           });
    

    Any ideas?

    Thanks and regards - Tony

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Could not get HttpClientProxyConfig for Integration.AccountSegments.IAccountSegmentsAppService. Volo.Abp.AbpException: Could not get HttpClientProxyConfig for Integration.AccountSegments.IAccountSegmentsAppService. at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase

    You need to configure the HTTP propxy

    https://abp.io/docs/latest/framework/api-development/static-csharp-clients#without-contracts-example

  • User Avatar
    0
    Tony_Albutt created

    Thanks If you look at the above comment, what am I missing to configure client proxy

    Where do I set the config for this?

            Configure<AbpHttpClientOptions>(options =>
            {
                options.HttpClientProxies.Add(typeof(ISubscriptionAppService), new HttpClientProxyConfig(typeof(ISubscriptionAppService), SaasHostRemoteServiceConsts.RemoteServiceName));
            });
    

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    I don't know your project details I guess you need to configure client proxy for Integration module

     public override void ConfigureServices(ServiceConfigurationContext context)
    {
        context.Services.AddStaticHttpClientProxies(
            typeof(IntegrationApplicationContractsModule).Assembly,
            .....
        );
        
        ....
    }
    
  • User Avatar
    0
    Tony_Albutt created

    Fantastic 🎉 so close now 😎

    If I change the endpoint on the external system side to [AllowAnonymous] , the current User is empty, but the tenant is identified. All that I need now is to set the current User information. Is their a user or admin user setting for the tenant that needs setting? Thank you This is the error on the Client Proxy side

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    If I change the endpoint on the external system side to [AllowAnonymous] , the current User is empty, but the tenant is identified.

    if you need current user info, don't use [AllowAnonymous]

  • User Avatar
    0
    Tony_Albutt created

    Yip, that's what I am trying to do when asking Is their a user or admin user setting for the tenant that needs setting 😁

    If anyone else wants to know how to add o user info to the Client Proxies, this is my solution. I don't know if there is another/better method, but the user is now authorised.

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