I have a module named BaseComponent with following AppService:
public interface IStaticDataTypeAppService : IApplicationService
{
Task<LoadResult> GetListAsync(DataSourceLoadOptionsCustomized options);
Task<BaseComponentResponseDto> BatchUpdateAsync(List<DXBatchUpdate> changes);
Task<StaticDataTypeViewDto?> GetNameByCodeAsync(string code);
}
public class StaticDataTypeAppService : BaseComponentAppService, IStaticDataTypeAppService
{
private readonly IStaticDataTypeRepository _staticDataTypeRepository;
private readonly IStaticDataStructureRepository _staticDataStructureRepository;
private readonly IEmployeeRepository _employeeRepository;
private readonly IStringLocalizer<BaseComponentResource> _baseLocalizer;
public StaticDataTypeAppService(
IStaticDataTypeRepository staticDataTypeRepository,
IStaticDataStructureRepository staticDataStructureRepository,
IEmployeeRepository employeeRepository,
IStringLocalizer<BaseComponentResource> baselocalizer
)
{
_staticDataTypeRepository = staticDataTypeRepository;
_staticDataStructureRepository = staticDataStructureRepository;
_employeeRepository = employeeRepository;
_baseLocalizer = baselocalizer;
}
...
}
I use this module in AMLReportService as following:
public interface ICustomStaticDataTypeAppService : IStaticDataTypeAppService
{
}
public class CustomStaticDataTypeAppService : StaticDataTypeAppService, ICustomStaticDataTypeAppService
{
public CustomStaticDataTypeAppService(IStaticDataTypeRepository staticDataTypeRepository, IStaticDataStructureRepository staticDataStructureRepository, IEmployeeRepository employeeRepository, IStringLocalizer<BaseComponentResource> baselocalizer) : base(staticDataTypeRepository, staticDataStructureRepository, employeeRepository, baselocalizer)
{
}
}
The purpose that I have to create Custom AppService for IStaticDataTypeAppService is: this module will be used in multiple services, so all of its APIs need to be renamed.
In AMLReportService swagger, I can see custom APs and work fine:

Static C# proxy is also generated normally as following:
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(ICustomStaticDataTypeAppService), typeof(CustomStaticDataTypeClientProxy))]
public partial class CustomStaticDataTypeClientProxy : ClientProxyBase<ICustomStaticDataTypeAppService>, ICustomStaticDataTypeAppService
{
public virtual async Task<LoadResult> GetListAsync(DataSourceLoadOptionsCustomized options)
{
return await RequestAsync<LoadResult>(nameof(GetListAsync), new ClientProxyRequestTypeValue
{
{ typeof(DataSourceLoadOptionsCustomized), options }
});
}
public virtual async Task<BaseComponentResponseDto> BatchUpdateAsync(List<DXBatchUpdate> changes)
{
return await RequestAsync<BaseComponentResponseDto>(nameof(BatchUpdateAsync), new ClientProxyRequestTypeValue
{
{ typeof(List<DXBatchUpdate>), changes }
});
}
public virtual async Task<StaticDataTypeViewDto> GetNameByCodeAsync(string code)
{
return await RequestAsync<StaticDataTypeViewDto>(nameof(GetNameByCodeAsync), new ClientProxyRequestTypeValue
{
{ typeof(string), code }
});
}
}
But in client side, in ServiceProxyScript, I can't find those APIs, I don't know why it's not generated (Only APIs in BaseComponent module are not generated, other APIs in AMLReportService are generated normally). Please help.
Hi,
I get this error when running a background worker after upgrading from v7.3.0 to v9.1.0: The data you have submitted has already been changed by another user. Discard your changes and try again
I found so many questions the same as mine but could not find any answer.
at Volo.Abp.IdentityModel.IdentityModelAuthenticationService.GetAccessTokenAsync(IdentityClientConfiguration configuration)
at Volo.Abp.IdentityModel.IdentityModelAuthenticationService.GetAccessTokenOrNullAsync(String identityClientName)
at Volo.Abp.IdentityModel.IdentityModelAuthenticationService.TryAuthenticateAsync(HttpClient client, String identityClientName)
at Volo.Abp.Http.Client.IdentityModel.IdentityModelRemoteServiceHttpClientAuthenticator.Authenticate(RemoteServiceHttpClientAuthenticateContext context)
at Volo.Abp.Http.Client.IdentityModel.Web.HttpContextIdentityModelRemoteServiceHttpClientAuthenticator.Authenticate(RemoteServiceHttpClientAuthenticateContext context)
at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase`1.RequestAsync(ClientProxyRequestContext requestContext)
at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase`1.RequestAsync[T](ClientProxyRequestContext requestContext)
at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase`1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments)
at MZH.MHIBS.JFSAService.TransactionReports.TransactionReportClientProxy.GenerateReportFileAsync() in ...
at MZH.MHIBS.BackgroundWorker.JFSAService.ScanReportFileWorker.SendReportFile() in ...
at MZH.MHIBS.BackgroundWorker.JFSAService.ScanReportFileWorker.Execute(IJobExecutionContext context) in ...
I get this error after upgrade microservice template from v7.3.0 to v9.1.0. Old version still works fine.
[web_80132ba5-d]: [10:43:56 ERR] ---------- RemoteServiceErrorInfo ----------
[web_80132ba5-d]: {
[web_80132ba5-d]: "code": null,
[web_80132ba5-d]: "message": "An error occurred during the ABP remote HTTP request. (The operation didn't complete within the allowed timeout of '00:00:30'.) See the inner exception for details.",
[web_80132ba5-d]: "details": null,
[web_80132ba5-d]: "data": null,
[web_80132ba5-d]: "validationErrors": null
[web_80132ba5-d]: }
[web_80132ba5-d]:
[web_80132ba5-d]: [10:43:56 ERR] An error occurred during the ABP remote HTTP request. (The operation didn't complete within the allowed timeout of '00:00:30'.) See the inner exception for details.
[web_80132ba5-d]: Volo.Abp.Http.Client.AbpRemoteCallException: An error occurred during the ABP remote HTTP request. (The operation didn't complete within the allowed timeout of '00:00:30'.) See the inner exception for details.
[web_80132ba5-d]: ---> Polly.Timeout.TimeoutRejectedException: The operation didn't complete within the allowed timeout of '00:00:30'.
[web_80132ba5-d]: ---> System.Threading.Tasks.TaskCanceledException: The operation was canceled.
[web_80132ba5-d]: ---> System.IO.IOException: Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request..
[web_80132ba5-d]: ---> System.Net.Sockets.SocketException (995): The I/O operation has been aborted because of either a thread exit or an application request.
[web_80132ba5-d]: --- End of inner exception stack trace ---
I tried to increase the timeout like this, but the error still occur.
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<AbpHttpClientBuilderOptions>(options =>
{
options.ProxyClientActions.Add((remoteServiceName, clientBuilder, client) =>
{
client.Timeout = TimeSpan.FromMinutes(60);
});
options.ProxyClientBuildActions.Add((remoteServiceName, clientBuilder) =>
{
clientBuilder.AddPolicyHandler(Policy.TimeoutAsync<HttpResponseMessage>(TimeSpan.FromMinutes(60)));
clientBuilder.AddResilienceHandler("MHIBS", builder =>
{
builder.AddTimeout(TimeSpan.FromMinutes(60));
});
clientBuilder.AddStandardResilienceHandler(opts =>
{
opts.TotalRequestTimeout.Timeout = TimeSpan.FromMinutes(60);
opts.AttemptTimeout.Timeout = TimeSpan.FromMinutes(60);
opts.CircuitBreaker.SamplingDuration = TimeSpan.FromMinutes(120);
});
});
});
}
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="9.0.3" /> <PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.4.0" />
Please help
I've created a report module and need to use this module in multiple microservices. In this module, I have some pages with following controllers
namespace MZH.MHIBS.Report.Controllers
{
[RemoteService(Name = ReportRemoteServiceConsts.RemoteServiceName)]
[Area(ReportRemoteServiceConsts.ModuleName)]
[Route("api/report/report-item")]
public class ReportItemController : ReportController, IReportItemAppService
{
protected IReportItemAppService ReportItemAppService { get; }
public ReportItemController(IReportItemAppService reportItemAppService)
{
ReportItemAppService = reportItemAppService;
}
[HttpPost]
[Route("batch-update")]
public Task BatchUpdateAsync(List<DXBatchUpdate> changes)
{
return ReportItemAppService.BatchUpdateAsync(changes);
}
[HttpGet]
public Task<LoadResult> GetListAsync(DataSourceLoadOptionsCustomized options)
{
return ReportItemAppService.GetListAsync(options);
}
}
}
Each microservice use different database. When using this module, each microservice will have the same tables. But I don't know how to separate the route of controllers for each microservice. Please help.
[HttpPost]
[UnitOfWork(true, System.Data.IsolationLevel.ReadCommitted)]
public async Task<Guid> CollectDataAsync<T>(string reportCode, string formData, string? permission = "") where T : CollectDataBaseDto
{
if (string.IsNullOrEmpty(permission))
{
throw new UserFriendlyException(_localizer["common_msg_DoNotPermission"]);
}
if (!await AuthorizationService.IsGrantedAsync(permission))
{
throw new UserFriendlyException(string.Format(_localizer["common_msg_DoNotPermission_Item"], permission));
}
if (CurrentUser == null)
{
throw new UserFriendlyException(new ArgumentNullException(nameof(CurrentUser)).Message);
}
if (CurrentTenant == null)
{
throw new UserFriendlyException(new ArgumentNullException(nameof(CurrentTenant)).Message);
}
T? paraObject = default(T);
if (!string.IsNullOrEmpty(formData))
{
paraObject = JsonConvert.DeserializeObject<T>(formData);
}
Dictionary<string, object> keyValueParams = new Dictionary<string, object>();
if (paraObject == null)
{
return Guid.Empty;
}
paraObject.ReportCode = reportCode;
if (CurrentUser != null && CurrentUser.Id.HasValue)
{
paraObject.CurrentUserId = CurrentUser.Id.Value;
string department = await GetCurrentDepartmentAsync();
if (!string.IsNullOrEmpty(department))
{
paraObject.Department = department;
}
}
if (CurrentTenant != null && CurrentTenant.Id.HasValue)
{
paraObject.TenantId = CurrentTenant.Id.Value;
}
Logger.LogInformation("Para object: {0}", paraObject.ObjectToString());
var properties = paraObject.GetType().GetProperties();
foreach (var prop in properties)
{
keyValueParams.Add(prop.Name, prop.GetValue(paraObject) ?? string.Empty);
}
using (_dataFilter.Disable<ISoftDelete>())
{
return await _reportDataRepository.CollectDataAsync(reportCode, paraObject.ReportDate, paraObject.Department, keyValueParams);
}
}
CollectDataAsync method in ReportDataRepository
public async Task<Guid> CollectDataAsync(string reportCode, DateTime reportDate, string department, Dictionary<string, object> keyValueParams)
{
if (string.IsNullOrEmpty(department))
return Guid.Empty;
var dbContext = await GetDbContextAsync();
await SetCommandTimeout(dbContext);
ReportType? reportType = await dbContext.ReportTypes.FirstOrDefaultAsync(a => a.ReportCode == reportCode && !a.IsDeleted);
if (reportType == null)
return Guid.Empty;
ReportStructure? reportStructure = await dbContext.ReportStructures.FirstOrDefaultAsync(a => a.ReportTypeId == reportType.Id && a.IsActive && !a.IsDeleted);
if (reportStructure == null)
return Guid.Empty;
ReportPeriod? reportPeriod = await dbContext.ReportPeriods.FirstOrDefaultAsync(a => a.ReportTypeId == reportType.Id && a.ReportDate.Date == reportDate.Date && !a.IsDeleted);
if (reportPeriod == null)
{
//create new report period for this report type
reportPeriod = new ReportPeriod(Guid.NewGuid());
reportPeriod.ReportTypeId = reportType.Id;
reportPeriod.ReportStructureId = reportStructure.Id;
reportPeriod.ReportDate = reportDate;
await dbContext.ReportPeriods.AddAsync(reportPeriod);
await dbContext.SaveChangesAsync();
}
if (await dbContext.ReportData.AnyAsync(a => a.ReportPeriodId == reportPeriod.Id && a.Department.ToLower() == department.ToLower()))
return reportPeriod.Id;
//Find all datasources and execute scripts
var datasources = dbContext.ReportDataSources.Where(a => a.ReportStructureId == reportStructure.Id && a.Department.Contains(department) && !a.IsDeleted
).OrderBy(a => a.RunningOrder);
foreach (var ds in datasources)
{
await ExecuteSQLCommand(ds, keyValueParams);
}
return reportPeriod.Id;
}
I check ReportPeriod table with these conditions: ReportPeriod? reportPeriod = await dbContext.ReportPeriods.FirstOrDefaultAsync(a => a.ReportTypeId == reportType.Id && a.ReportDate.Date == reportDate.Date && !a.IsDeleted); and expect that it can not have > 1 record with the same ReportType, ReportDate and not deleted.
But when I quickly click Collect Data button on UI 4 times. It still creates 4 records in database.
Where am I wrong?
ABP Framework version: v7.3.0
UI Type: MVC
Database System: EF Core (SQL Server)
Tiered (for MVC) or Auth Server Separated (for Angular): yes
Exception message and full stack trace:
Steps to reproduce the issue: I tried to increase HttpClient timeout but failed. The long running task is in ReportModule which is used in AMLReportService, so I tried to increase HttpClient like this:
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(OpenLdapManager), typeof(ILdapManager), typeof(LdapManager), typeof(MZHOpenLdapManager))]
public class MZHOpenLdapManager : OpenLdapManager
{
public MZHOpenLdapManager(ILdapSettingProvider ldapSettingProvider) : base(ldapSettingProvider)
{
}
public override async Task<bool> AuthenticateAsync(string username, string password)
{
using (var conn = await CreateLdapConnectionAsync())
{
try
{
Logger.LogInformation("Login with admin account.");
await AuthenticateLdapConnectionAsync(conn, await NormalizeUserNameAsync(await LdapSettingProvider.GetUserNameAsync()), await LdapSettingProvider.GetPasswordAsync());
Logger.LogInformation("Search username");
//conn.SetOption(LdapForNet.Native.Native.LdapOption.LDAP_OPT_REFERRALS, "ignore");
SearchRequest request = new SearchRequest(await GetBaseDnAsync(), await GetUserFilterAsync(username), LdapForNet.Native.Native.LdapSearchScope.LDAP_SCOPE_SUBTREE);
request.SizeLimit = 1;
SearchOptionsControl SuppressReferrals = new SearchOptionsControl(SearchOption.DomainScope);
request.Controls.Add(SuppressReferrals);
//var searchResults = await conn.SearchAsync(await GetBaseDnAsync(), await GetUserFilterAsync(username));
SearchResponse response = conn.SendRequest(request) as SearchResponse;
Logger.LogInformation("Get first item searched");
var userEntry = response.Entries.First();
Logger.LogInformation("Login with username");
await AuthenticateLdapConnectionAsync(conn, userEntry.Dn, password);
Logger.LogInformation("Login LDAP done");
return true;
}
catch (Exception e)
{
Logger.LogException(e);
}
return false;
}
}
protected override async Task<string> NormalizeUserNameAsync(string userName)
{
return $"cn={userName},{await LdapSettingProvider.GetBaseDcAsync()}";
}
protected override Task<string> GetUserFilterAsync(string userName)
{
return Task.FromResult($"(&(objectClass=user)(sAMAccountName={userName}))");
}
protected override Task<string> GetBaseDnAsync()
{
return LdapSettingProvider.GetDomainAsync();
}
protected override Task<string> GetUserEmailAsync(LdapEntry ldapEntry)
{
Logger.LogInformation("Try to get email infor - start");
string email = ldapEntry.ToDirectoryEntry().GetAttribute("mail")?.GetValue<string>();
if (string.IsNullOrWhiteSpace(email))
email = ldapEntry.ToDirectoryEntry().GetAttribute("userPrincipalName")?.GetValue<string>();
Logger.LogInformation("Try to get email infor - end");
return Task.FromResult(email);
}
Login with LDAP successfully, but very slowly. I check logs see below:
In the red area, it takes 10 second after LDAP login done and continue get email infor. Could you pls show me what Abp was doing during that time?

[web_bd1ce1f9-2]: [18:00:24 INF] Request starting HTTP/1.1 GET http://mzh.mhibs.web:7004/Account/Login - null null
[web_bd1ce1f9-2]: [18:00:24 INF] Executing endpoint 'MZH.MHIBS.Web.Controllers.AccountController.Login (MZH.MHIBS.Web)'
[web_bd1ce1f9-2]: [18:00:24 INF] Route matched with {action = "Login", controller = "Account", area = "", page = ""}. Executing controller action with signature Microsoft.AspNetCore.Mvc.ActionResult Login(System.String, System.String) on controller MZH.MHIBS.Web.Controllers.AccountController (MZH.MHIBS.Web).
[web_bd1ce1f9-2]: [18:00:24 INF] Executing action method MZH.MHIBS.Web.Controllers.AccountController.Login (MZH.MHIBS.Web) - Validation state: Valid
[web_bd1ce1f9-2]: [18:00:24 INF] Executed action method MZH.MHIBS.Web.Controllers.AccountController.Login (MZH.MHIBS.Web), returned result Microsoft.AspNetCore.Mvc.ChallengeResult in 0.037ms.
[web_bd1ce1f9-2]: [18:00:24 INF] Executing ChallengeResult with authentication schemes (["oidc"]).
[web_bd1ce1f9-2]: [18:00:24 INF] AuthenticationScheme: oidc was challenged.
[web_bd1ce1f9-2]: [18:00:24 INF] Executed action MZH.MHIBS.Web.Controllers.AccountController.Login (MZH.MHIBS.Web) in 4.7096ms
[web_bd1ce1f9-2]: [18:00:24 INF] Executed endpoint 'MZH.MHIBS.Web.Controllers.AccountController.Login (MZH.MHIBS.Web)'
[web_bd1ce1f9-2]: [18:00:24 INF] Request finished HTTP/1.1 GET http://mzh.mhibs.web:7004/Account/Login - 302 0 null 5.572ms
[web_bd1ce1f9-2]: [18:00:25 INF] Request starting HTTP/1.1 POST http://mzh.mhibs.web:7004/signin-oidc - application/x-www-form-urlencoded 1586
[web_bd1ce1f9-2]: [18:00:25 WRN] '.AspNetCore.Correlation.zwwe_Ao2xW7750a7k0U1t8rW5pCQMvknu6aP7K0j1kw' cookie not found.
[web_bd1ce1f9-2]: [18:00:25 INF] Error from RemoteAuthentication: Correlation failed..
[web_bd1ce1f9-2]: [18:00:25 ERR] An unhandled exception has occurred while executing the request.
[web_bd1ce1f9-2]: Microsoft.AspNetCore.Authentication.AuthenticationFailureException: An error was encountered while handling the remote login.
[web_bd1ce1f9-2]: ---> Microsoft.AspNetCore.Authentication.AuthenticationFailureException: Correlation failed.
[web_bd1ce1f9-2]: --- End of inner exception stack trace ---
[web_bd1ce1f9-2]: at Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler`1.HandleRequestAsync()
[web_bd1ce1f9-2]: at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
[web_bd1ce1f9-2]: at Prometheus.HttpMetrics.HttpRequestDurationMiddleware.Invoke(HttpContext context)
[web_bd1ce1f9-2]: at Prometheus.HttpMetrics.HttpRequestCountMiddleware.Invoke(HttpContext context)
[web_bd1ce1f9-2]: at Prometheus.HttpMetrics.HttpInProgressMiddleware.Invoke(HttpContext context)
[web_bd1ce1f9-2]: at Volo.Abp.AspNetCore.Security.AbpSecurityHeadersMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
[web_bd1ce1f9-2]: at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext()
[web_bd1ce1f9-2]: --- End of stack trace from previous location ---
[web_bd1ce1f9-2]: at Volo.Abp.AspNetCore.Tracing.AbpCorrelationIdMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
[web_bd1ce1f9-2]: at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext()
[web_bd1ce1f9-2]: --- End of stack trace from previous location ---
[web_bd1ce1f9-2]: at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
[web_bd1ce1f9-2]: at Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
[web_bd1ce1f9-2]: at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext()
[web_bd1ce1f9-2]: --- End of stack trace from previous location ---
[web_bd1ce1f9-2]: at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
[web_bd1ce1f9-2]: [18:00:25 INF] Request finished HTTP/1.1 POST http://mzh.mhibs.web:7004/signin-oidc - 500 null text/html; charset=utf-8 5.2675ms