Is there a way to run both versions of SignalR in parallel server-side (Core, Angular, v5.5.0)? I'm asking because I still have to support some IoT-Clients using AspNet.SignalR.
I tried implementing stuff the way it was implemented in v4.6.0 - but no luck so far ... Client's HubConnection.State is Connected, but invoking something doesn't work (500, internal server error).
Any ideas?
5 Answer(s)
-
0
This is not recommended. If you can migrate SignalR to SignalR Core, it's best.
-
0
<cite>maliming: </cite> This is not recommended. If you can migrate SignalR to SignalR Core, it's best.
Thanks for your reply! I already thought so :lol: Well, it would be for a short period of time only (a couple of days) - just till all clients have updated to the latest version, speaking AspNetCore.SignalR finally.
So, even if it is not recommended, I'd still like to do it - it would make the upgrade process a lot smoother. But if it is not possible at all, then I will have to figure out something else (the goal is to avoid IoT-Client downtime).
-
0
I managed to figure out that the Internal Server Error has to do with my Hub class using dependency injection. So, I tried to register my Hub class and its dependencies in Startup.cs using GlobalHost.DependencyResolver. So far, my Client is able to invoke the hub method correctly. But the hub method itself fails when accessing the dependencies - they are all null … it's the same when I try to resolve dependencies in hub class constructor …
How do I resolve dependencies in a hub class correctly?
-
0
[https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.Web.SignalR/Web/SignalR/Hubs/AbpHubBase.cs])
[https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.AspNetCore.SignalR/AspNetCore/SignalR/Hubs/AbpHubBase.cs])
You can see it in ABP's source code for Signalr, and don't do anything particularly complicated code wrapping.
When you are dependent on AbpAspNetCoreSignalRModule and AbpWebSignalRModule, the last dependent module will replace the previous dependency injection, which may cause problems with the dependency.
Solution: You can paste the AbpWebSignalRModule related source code into your project. As a transition, simply modify the source code to use the class directly instead of relying on the interface.
-
0
It finally works!
I simply dependency-inject IocManager to my Hub, there i can then resolve all other dependencies.
Startup.cs
GlobalHost.DependencyResolver.Register(typeof(MySignalRHub), () => new MySignalRHub(IocManager.Instance));
MySignalRHub.cs
private readonly IIocManager _iocManager; public MySignalRHub(IIocManager iocManager) { _iocManager = iocManager; } public async Task SomeMethod() { using (var scope = _iocManager.CreateScope()) { var repClassA = scope.Resolve<IRepository<ClassA>>(); var srvClassA = scope.Resolve<IClassAAppService>(); // ... } }