Base solution for your next web application
Open Closed

Automatically refreshing auth tokens with a SignalR connection #11252


User avatar
0
tusksoft created
  • What is your product version? 10.2.0
  • What is your product type (Angular or MVC)? Angular
  • What is product framework type (.net framework or .net core)? .NET Core
  • What is ABP Framework version? 6.2.0

We have a custom SignalR hub that is meant to handle long-running connections, usually for multiple days. This is a problem with auth tokens because when they expire, the connection dies. The vanilla SignalR NPM package from Microsoft exposes an accessTokenFactory callback in the HubConnectionBuilder options, but the ABP abstraction for SignalR does not provide access to these options. How can we manage refreshing auth tokens on the client side for long-running SignalR connections?

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

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

    Hi @tusksoft

    For now, you can copy https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.Web.Resources/Abp/Framework/scripts/libs/abp.signalr-client.js to your project and modify it according to your needs. We will add this option for the next release, please follow https://github.com/aspnetboilerplate/aspnetboilerplate/issues/6538

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    tusksoft created

    Hi @tusksoft

    For now, you can copy https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.Web.Resources/Abp/Framework/scripts/libs/abp.signalr-client.js to your project and modify it according to your needs. We will add this option for the next release, please follow https://github.com/aspnetboilerplate/aspnetboilerplate/issues/6538

    Hello @ismcagdas

    We recently upgraded to ABP 8.0 and still do not see the withUrlOptions property available in the abp.signalr namespace. It appears that the abp.signalr.d.ts type definition file does not include the new property. When can we expect this to be fixed?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @tusksoft

    Did you also update abp-web-resources and abp-ng2-module to latest version ?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    tusksoft created

    Hi @tusksoft

    Did you also update abp-web-resources and abp-ng2-module to latest version ?

    Yes. Our Angular project is using abp-web-resources version 5.7.0 and abp-ng2-module version 8.0.0. Our AN0 version is the latest version 11.4.0. However, now that I'm looking at the change log for AN0, I see that AN0 11.4.0 only includes ABP 7.4. NPM does not list a version 7.4.0 for the abp-ng2-module package, which is why we are using version 8.0.0 instead.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    It seems like you are right, abp.signalr.d.ts is not updated. However, if you set abp.signalr.withUrlOptions, the JS code is using this and it should work. Could you try this ? We will update abp.signalr.d.ts with the next minor version.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)