Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

How to Set the Expiration time for an user logon? #3891


User avatar
0
trendline created

My application needs to run as unattended, once the user login from a web browser, the application needs to be running always, and the user should keep to logon so the user could receive real time notifications, using the default settings of ZERO, from the user logon after a couple of hours, the real time communication (implemented by SignalR) with warning logs that the current user is not login.

Is there a way that could set a long expiration for the user logon?

I am using IOnlineClientManager to get all clients and sent real time message to them, is that if the user is out of logon expiration time, it still could send real time message to the user? because I found that the logon user still could stay on the web in the browser after a serveral hours, even SignalR logged the exception "the current user is not login".


4 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @trendline,

    If user will be stayed as logged in until user's first server side action. We currently don't check if user is logged out or not in the client side.

    If you want to keep user logged in even if user does not perform any action for a long time, you can create a client side function which calls an empty serverside method with javascript's setInterval. You can do it in 1 minute period, so user will be logged in in that case.

    Thanks.

  • User Avatar
    0
    trendline created

    Is there a way that could do this on server side? Before, I set internal to call server method via JavaScript to get data to client, the user could always stayed as logged in. Now, I upgraded my application use SignalR broadcast data to client, and the current logged in user could get notifications if the broadcasted data with an exception, but after a duration, the user will logout automatically, then the user cannot get notifications any more, and logs also recorded some warning information that current user is not logged in the system. Exception like below:

    ARN  2017-09-19 21:53:49,110 [71   ] ng.ESC.EquipmentStateCurrentCommunicator - Could not send Grading equipment current state to user
    WARN  2017-09-19 21:53:49,126 [71   ] ng.ESC.EquipmentStateCurrentCommunicator - Abp.Authorization.AbpAuthorizationException: 当前用户没有登录到系统!
       at Abp.Authorization.AuthorizationHelper.<AuthorizeAsync>d__19.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Abp.Authorization.AuthorizationHelper.<CheckPermissions>d__22.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Abp.Authorization.AuthorizationHelper.<AuthorizeAsync>d__20.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task)
       at Nito.AsyncEx.AsyncContext.<>c__DisplayClass15_0.<Run>b__0(Task t)
       at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke()
       at System.Threading.Tasks.Task.Execute()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task)
       at Nito.AsyncEx.AsyncContext.Run(Func`1 action)
       at Abp.Authorization.AuthorizationHelperExtensions.Authorize(IAuthorizationHelper authorizationHelper, MethodInfo methodInfo, Type type)
       at Abp.Authorization.AuthorizationInterceptor.Intercept(IInvocation invocation)
       at Castle.DynamicProxy.AbstractInvocation.Proceed()
       at Abp.Domain.Uow.UnitOfWorkInterceptor.PerformAsyncUow(IInvocation invocation, UnitOfWorkOptions options)
       at Abp.Domain.Uow.UnitOfWorkInterceptor.PerformUow(IInvocation invocation, UnitOfWorkOptions options)
       at Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation)
       at Castle.DynamicProxy.AbstractInvocation.Proceed()
       at Abp.Auditing.AuditingInterceptor.Intercept(IInvocation invocation)
       at Castle.DynamicProxy.AbstractInvocation.Proceed()
       at Abp.Runtime.Validation.Interception.ValidationInterceptor.Intercept(IInvocation invocation)
       at Castle.DynamicProxy.AbstractInvocation.Proceed()
       at Castle.Proxies.GradingEquipmentStateCurrentAppServiceProxy.GetEquipmentStateCurrent(GetGradingEquipmentStateCurrentInput input)
    

    And, my code like below:

    /// &lt;summary&gt;
            /// Initializes a new instance of the &lt;see cref=&quot;EquipmentStateCurrentHub&quot;/&gt; class.
            /// &lt;/summary&gt;
            public EquipmentStateCurrentHub(
                IEquipmentStateCurrentCommunicator equipmentStateCurrentCommunicator,
                ILocalizationManager localizationManager)
            {
                _equipmentStateCurrentCommunicator = equipmentStateCurrentCommunicator;
                _localizationManager = localizationManager;
    
                Logger = NullLogger.Instance;
                AbpSession = NullAbpSession.Instance;
            }
    
            public async Task&lt;string&gt; GetEquipmentCurentState(GetEquipmentStateCurrentByProcessStageInput input)
            {
                var user = AbpSession.ToUserIdentifier();
    
                try
                {
                    await _equipmentStateCurrentCommunicator.SendEquipmentCurrentStateToClient(input, user);
                    return string.Empty;
                }
                catch (UserFriendlyException ex)
                {
                    Logger.Warn("Could not send CG conveyor equipment state to client: " + Context.ConnectionId);
                    Logger.Warn(ex.ToString(), ex);
                    return ex.Message;
                }
                catch (Exception ex)
                {
                    Logger.Warn("Could not send CG conveyor equipment state to user: " + Context.ConnectionId);
                    Logger.Warn(ex.ToString(), ex);
                    return _localizationManager.GetSource("AbpWeb").GetString("InternalServerError");
                }
    

    I am using NullABPSession.Instance as a property injection to get AbpSession, is this way I can get the current login user?

    Is there a way could set a long time expirations for AbpSession?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @trendline,

    If you want to extend session timeout, you can do it just like any other ASP.NET application. Have you searched on the web for this ?

  • User Avatar
    0
    trendline created

    Not yet, I have changed the notification publish mode, current I only publish the notification to the subscriber, not to a specified user. Using Abp Notification System.

    Not any more AbpSession.ToUserIdentifier() being used, but I still could get the exception "current user not logged on the system" in log.

    Any suggestions?