- ABP Framework version: v8.2.1
- UI Type: Angular
- Database System: EF Core (MySQL)
- Tiered (for MVC) or Auth Server Separated (for Angular): Auth Server Separated
- Exception message and full stack trace:
- Steps to reproduce the issue:
I have a microservice template project with Angular UI. Here I have a microservice called FormsService, and I am using one of the API endpoints of this microservice in my AuthServer. For the FormsService I am using the dynamic proxies to detect the API endpoints when used as a remote service in any other service (AuthServer in my case). I have used AddHttpClientProxies method in my FormsServiceHttpApiClientModule file to configure the dynamic proxies. And in my AuthServer's appsettings.json I have written
"RemoteServices": { "Default": { "BaseUrl": "https://localhost:44325" } }
so that it can redirect to the WebGateway (port: 44325) and from there it should be re-routed to the FormsService's API endpoint.
In order to use the dynamic proxy for the FormsService, I have also given the dependency of FormsServiceHttpApiClientModule in the WebGateway project (AuthServerModule.cs file).
I was previously using the ABP version 7.3.2, and now I have upgraded it to version 8.2.1. In the older version it was working fine, but in the 8.2.1 version it's giving the following error while trying to use that endpoint from AuthServer (I have given the reference of FormsService in the AuthServer and there in the Register.cs file I have injected the AppService in the constructor of Register.cs file and using the method of that AppService):
An unhandled exception occurred while processing the request. AbpException: Could not find remote action for method: System.Threading.Tasks.Task`1[Volo.Forms.Forms.FormWithDetailsDto] GetRegistrationFormAsync(System.Guid) on the URL: https://localhost:44325 Volo.Abp.Http.Client.DynamicProxying.ApiDescriptionFinder.FindActionAsync(HttpClient client, string baseUrl, Type serviceType, MethodInfo method)
Please suggest.
10 Answer(s)
-
0
hi
Have you added the
FormsHttpApiModule(Volo.Forms.HttpApi)
The https://localhost:44325/api/abp/api-definition endpoint should contain the form apis.
-
0
Yes, I have added the FormsServiceHttpApiModule dependency in my WebGatewayModule.cs file, but when I hit the https://localhost:44325/api/abp/api-definition endpoint, it shows the endpoints of only the Administration service.
-
0
My forms service is running on the port 44395, and when I hit the https://localhost:44395/api/abp/api-definition endpoint, all the API endpoints are there in the response, including the one that I am trying to use in the AuthServer.
-
0
hi
Can you share a demo project? I will download and check it.
Thanks
liming.ma@volosoft.com
-
0
Can we set-up a meeting to resolve the issue?
-
0
Microservices projects are more complicated,
You can create a new ms template project and try to add your code.
Thanks.
-
0
As you mentioned, the https://localhost:44325/api/abp/api-definition endpoint should return the list of all the endpoints. I checked this in the older version (7.3.2), there it was returning all the endpoints of the application, but in the upgraded version (8.2.1), when hitting the same endpoint, it only returned the following endpoints :
{ "modules": { "abp": {}, "auditLogging": {}, "featureManagement": {}, "fileManagement": {}, "gdpr": {}, "languageManagement": {}, "permissionManagement": {}, "settingManagement": {}, "textTemplateManagement": {} }, "types": {} }
(Because of the words limit I have removed the internal content of each module. The point here is that there is no endpoint in this JSON which corresponds to any of my microservices). This is happening in the newer version.
-
0
hi
Microservices are more complex. Can you share a project? So I can debug and find the cause.
Thanks liming.ma@volosoft.com
-
0
I added the RemoteService endpoints of the FormsService which is https://localhost:44395 in the appsettings.json file of the AuthServer (where I am trying to make the API call). And I changed the AddStaticHttpClientProxies to AddHttpClientProxies in the FormsServiceHttpApiClientModule.cs file. And it works fine.
But when I keep the AddStaticHttpClientProxies to use the static proxies, it throws the following error :
2024-08-12 13:02:59.777 +05:30 [ERR] An exception was thrown while activating λ:Volo.Abp.Http.Client.ClientProxying.IClientProxyApiDescriptionFinder -> Volo.Abp.Http.Client.ClientProxying.ClientProxyApiDescriptionFinder. Autofac.Core.DependencyResolutionException: An exception was thrown while activating λ:Volo.Abp.Http.Client.ClientProxying.IClientProxyApiDescriptionFinder -> Volo.Abp.Http.Client.ClientProxying.ClientProxyApiDescriptionFinder. ---> Autofac.Core.DependencyResolutionException: An exception was thrown while invoking the constructor 'Void .ctor(Volo.Abp.VirtualFileSystem.IVirtualFileProvider, Volo.Abp.Json.IJsonSerializer)' on type 'ClientProxyApiDescriptionFinder'. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Volo.Abp.Http.Client.ClientProxying.ClientProxyApiDescriptionFinder.Initialize() at lambda_method80(Closure, Object[])
And I tried to check the code, and it turned out that it's coming from ClientProxyBase file from the Volo.Abp.Http.Client package (namespace : Volo.Abp.Http.Client.ClientProxying), here there's this propery named IClientProxyApiDescriptionFinder which is throwing the NullReferenceExceoption because of which it's not able to create the proxies.
protected virtual ClientProxyRequestContext BuildHttpProxyClientProxyContext(string methodName, ClientProxyRequestTypeValue? arguments = null) { if (arguments == null) { arguments = new ClientProxyRequestTypeValue(); } var methodUniqueName = $"{typeof(TService).FullName}.{methodName}.{string.Join("-", arguments.Values.Select(x => TypeHelper.GetFullNameHandlingNullableAndGenerics(x.Key)))}"; var action = ClientProxyApiDescriptionFinder.FindAction(methodUniqueName); if (action == null) { throw new AbpException($"The API description of the {typeof(TService).FullName}.{methodName} method was not found!"); } var actionArguments = action.Parameters.GroupBy(x => x.NameOnMethod).ToList(); if (action.SupportedVersions != null && action.SupportedVersions.Any()) { //TODO: make names configurable actionArguments.RemoveAll(x => x.Key == "api-version" || x.Key == "apiVersion"); } return new ClientProxyRequestContext( action, actionArguments .Select((x, i) => new KeyValuePair<string, object>(x.Key, arguments.Values[i].Value)) .ToDictionary(x => x.Key, x => x.Value), typeof(TService)); }
From this piece of code the problem seems to be coming, here in the code the line
var action = ClientProxyApiDescriptionFinder.FindAction(methodUniqueName);
the ClientProxyApiDescriptionFinder property of the class which is coming as null and hence the whole action is failing.
-
0
hi
the ClientProxyApiDescriptionFinder property of the class which is coming as null
Have you depended on the
AbpHttpClientModule
?[DependsOn(typeof(AbpHttpClientModule))]
If you can share a project, we will confirm the problem as soon as possible. : )