Hi Support Team,
While running jobs as a background process in our Production site using HangFire, our users are getting an exception intermittently.
Exception is:
An exception occurred during performance of the job. Abp.UI.UserFriendlyException
[Session.Tenant id is null! Possible problems: No user logged in or current logged in user in a host user (Tenant id is always null for host users).]
Abp.UI.UserFriendlyException: [Session.Tenant id is null! Possible problems: No user logged in or current logged in user in a host user (Tenant id is always null for host users).] at endurohub.Job.JobAppService.RunAutomationStep(Int32 step, Int32 tenantId, Int64 userId, Int32 orderId) in D:\a\1\s\src\endurohub.Application\Job\JobAppService.cs:line 188 at endurohub.Job.JobAppService.UpdateJobFileInBackground(UpdateJobFileInput input, Int32 tenantId, Int64 userId) in D:\a\1\s\src\endurohub.Application\Job\JobAppService.cs:line 169 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Our Code is:
public async Task UpdateJobFile(UpdateJobFileInput input)
{
_backgroundJobClient.Enqueue<JobAppService>(x => x.UpdateJobFileInBackground(input, AbpSession.GetTenantId(), AbpSession.GetUserId()));
}
public async Task UpdateJobFileInBackground(UpdateJobFileInput input, int tenantId, long userId)
{
//Do the job - calling many functions, passing tenantId and userId to those functions
}
Product version - V10.2.0 Product type- Angular Product framework type - .Net Core Hosting - Azure
Please let us know any suggestions.
1 Answer(s)
-
0
Hi Support team,
Please ignore this ticket for time being.I guess it is problem of calling AbpSession.GetTenantId() on background functions in a specific scenario.
Best regards