Open Closed

Abp Generate-Proxies Issue With Authentication #4973


User avatar
0
cverga created

Greetings, We are having a problem with ABP's CLI command to generate proxies in the "HttpApi.Client" projects. We have 2 solutions: one for the Admins of the application and one for the Public. The problem seems to be on both.

  • ABP Framework version: v6.0.2
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes / no
  • Exception message and stack trace:
    [13:31:27 INF] ABP CLI ([https://abp.io](https://abp.io))
    [13:31:31 ERR] Response status code does not indicate success: 500 (Internal Server Error). System.Net.Http.HttpRequestException: Response status code does not indicate success: 500 (Internal Server Error). at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode() at System.Net.Http.HttpClient.GetStringAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken) at Volo.Abp.Cli.ServiceProxying.ServiceProxyGeneratorBase`1.GetApplicationApiDescriptionModelAsync(GenerateProxyArgs args) in D:\ci\Jenkins\w orkspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\ServiceProxying\ServiceProxyGeneratorBase.cs:line 36 at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.GenerateProxyAsync(GenerateProxyArgs args) in D:\ci\Jenkins\workspace\abp- framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\ServiceProxying\CSharp\CSharpServiceProxyGenerator.cs:line 78 at Volo.Abp.Cli.Commands.ProxyCommandBase`1.ExecuteAsync(CommandLineArgs commandLineArgs) in D:\ci\Jenkins\workspace\abp-framework-release\ab p\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\Commands\ProxyCommandBase.cs:line 56 at Volo.Abp.Cli.CliService.RunInternalAsync(CommandLineArgs commandLineArgs) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\s rc\Volo.Abp.Cli.Core\Volo\Abp\Cli\CliService.cs:line 167 at Volo.Abp.Cli.CliService.RunAsync(String[] args) in D:\ci\Jenkins\workspace\abp-framework-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\ Abp\Cli\CliService.cs:line 75
* **Log Message**:
    2023-04-27 13:31:31.775 +03:00 [ERR] Exception occurred while processing message.
    System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'System.String'.
    \-\-\-\> System\.IO\.IOException: IDX20804: Unable to retrieve document from: 'System\.String'\.
    \-\-\-\> System\.Net\.Http\.HttpRequestException: No connection could be made because the target machine actively refused it\. \(localhost:44390\)
    \-\-\-\> System\.Net\.Sockets\.SocketException \(10061\): No connection could be made because the target machine actively refused it\.
    at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
    at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
    at System\.Net\.Sockets\.Socket\.g\_\_WaitForConnectWithCancellation\|277\_0\(AwaitableSocketAsyncEventArgs saea\, ValueTask connectTask\, CancellationToken cancellationToken\)
    at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
    \-\-\- End of inner exception stack trace \-\-\-
    at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
    at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
    at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
    at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(HttpRequestMessage request)
    at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.GetHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(String address, CancellationToken cancel) --- End of inner exception stack trace --- at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(String address, CancellationToken cancel) at Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfigurationRetriever.GetAsync(String address, IDocumentRetriever retriever, CancellationToken cancel) at Microsoft.IdentityModel.Protocols.ConfigurationManager`1.GetConfigurationAsync(CancellationToken cancel)
    \-\-\- End of inner exception stack trace \-\-\-
    at Microsoft.IdentityModel.Protocols.ConfigurationManager`1.GetConfigurationAsync(CancellationToken cancel) at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync() at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync() at Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.AuthenticateAsync()
    at Microsoft.AspNetCore.Authentication.AuthenticationService.AuthenticateAsync(HttpContext context, String scheme)
    at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
    at Volo.Abp.AspNetCore.Tracing.AbpCorrelationIdMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
    at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c\_\_DisplayClass6\_1.<b\_\_1>d.MoveNext()
    \-\-\- End of stack trace from previous location \-\-\-
    at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
    at Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
    at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c\_\_DisplayClass6\_1.<b\_\_1>d.MoveNext()
    \-\-\- End of stack trace from previous location \-\-\-
    at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
    2023-04-27 13:31:31.779 +03:00 [ERR] An unhandled exception has occurred while executing the request.
    System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'System.String'.
    \-\-\-\> System\.IO\.IOException: IDX20804: Unable to retrieve document from: 'System\.String'\.
    \-\-\-\> System\.Net\.Http\.HttpRequestException: No connection could be made because the target machine actively refused it\. \(localhost:44390\)
    \-\-\-\> System\.Net\.Sockets\.SocketException \(10061\): No connection could be made because the target machine actively refused it\.
    at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
    at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
    at System\.Net\.Sockets\.Socket\.g\_\_WaitForConnectWithCancellation\|277\_0\(AwaitableSocketAsyncEventArgs saea\, ValueTask connectTask\, CancellationToken cancellationToken\)
    at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
    \-\-\- End of inner exception stack trace \-\-\-
    at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
    at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
    at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
    at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(HttpRequestMessage request)
    at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.GetHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpClient.&lt;SendAsync&gt;g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(String address, CancellationToken cancel) --- End of inner exception stack trace --- at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(String address, CancellationToken cancel) at Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfigurationRetriever.GetAsync(String address, IDocumentRetriever retriever, CancellationToken cancel) at Microsoft.IdentityModel.Protocols.ConfigurationManager`1.GetConfigurationAsync(CancellationToken cancel)
    \-\-\- End of inner exception stack trace \-\-\-
    at Microsoft.IdentityModel.Protocols.ConfigurationManager`1.GetConfigurationAsync(CancellationToken cancel) at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync() at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync() at Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.AuthenticateAsync()
    at Microsoft.AspNetCore.Authentication.AuthenticationService.AuthenticateAsync(HttpContext context, String scheme)
    at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
    at Volo.Abp.AspNetCore.Tracing.AbpCorrelationIdMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
    at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c\_\_DisplayClass6\_1.<b\_\_1>d.MoveNext()
    \-\-\- End of stack trace from previous location \-\-\-
    at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
    at Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
    at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c\_\_DisplayClass6\_1.<b\_\_1>d.MoveNext()
    \-\-\- End of stack trace from previous location \-\-\-
    at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
    2023-04-27 13:31:31.816 +03:00 [INF] Request finished HTTP/1.1 GET [https://localhost:44370/api/abp/api-definition](https://localhost:44370/api/abp/api-definition) \- \- \- 500 \- text/plain;\+charset=utf\-8 4230\.1589ms
  • Steps to reproduce the issue:
    1. Start new Instance of HttpApi.Host project.
    2. In a terminal, go to the project folder of the corresponding HttpApi.Client project.
    3. Run: abp generate-proxy -t csharp -url <HttpApi.Host_url>

To clarify https://localhost:44370 is our HttpApi.Host URL~~~~ and https://localhost:44390 our Authentication Server URL.

A work around we found was that if we started the whole solution, the problem was solved. Interestingly, if we comment out the ConfigureAuthentication on the HttpApi.Host Configuration and try to reproduce the problem, it is solved. However, before the migration to OpenIdDict it was working fine.


3 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    I will check it

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    This is a problem of ABP CLI. we will fix it in the next version. you need also to run the Authserver currently

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    https://github.com/abpframework/abp/issues/16403

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