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

AbpSession not injected #1165


User avatar
0
ioannes created

Hi,

I am implamanting SignalR Hub. I am injecting IAbpSession as you described in documentation. Problem is that its not injected, only nullinstance is retrieved. On the other hand Logger works as expected. I am using abp version 0.8.4.

public class PrintDigitalHub : Hub, ITransientDependency
    {
        public ILogger Logger { get; set; }

        public IAbpSession AbpSession { get; set; }

        private readonly IOnlineClientManager _onlineClientManager;

        public PrintDigitalHub(IOnlineClientManager onlineClientManager, IIocResolver iocResolver)
        {
            _onlineClientManager = onlineClientManager;
            Logger = NullLogger.Instance;
            AbpSession = NullAbpSession.Instance;
        }

        public async override Task OnConnected()
        {
            await base.OnConnected();

            var client = new OnlineClient(
                Context.ConnectionId,
                GetIpAddressOfClient(),
                AbpSession.TenantId,
                AbpSession.UserId
                );

            Logger.Debug("A client is connected: " + client);

            _onlineClientManager.Add(client);
        }

Thanks for your help.


4 Answer(s)
  • User Avatar
    0
    ioannes created

    After upgrade everything works, probably some old refrence caused this issue.

  • User Avatar
    0
    ratosoft created

    I have the same problem.

    Update references not solve it to me.

  • User Avatar
    0
    hikalkan created
    Support Team

    Can you inject it in your constructor?

  • User Avatar
    0
    ratosoft created

    Testing inside a signalR Hub class.

    Using NullAbpSession: {Abp.Runtime.Session.NullAbpSession} ImpersonatorTenantId: null ImpersonatorUserId: null MultiTenancySide: Tenant TenantId: null UserId: null

    Injecting AbpSession in constructor (UserId still null): {Abp.Runtime.Session.IdentityFrameworkClaimsAbpSession} ImpersonatorTenantId: 1 ImpersonatorUserId: null MultiTenancySide: Tenant TenantId: 1 UserId: null

    Thanks