@twenzel ach… ok so this still has the same problem I was having with Autofac in that the services aren’t being updated. For example,
IHubContext<T> which is needed if an NSB handler ever hopes to being to communicate with a user connected to the hub. The problem is that as user connect and disconnect from the hub,
IHubContext gets updated by the framework. It would appear that those changes aren’t being picked up in NSB’s internal service collection, almost as if the service collection is being copied from IServiceCollection instead of adapted, if that makes sense. I haven’t actually looked at the code yet, but this is what I guess is happening.
The result is:
- service starts up
- The current state of
IHubContext is registered with NSB
- A user connects and
IHubContext is updated with that connection info
- A message is received by the NSB handler which requests
- The handler tries to send a message to the connected user but the user’s connection doesn’t exist on this instance of
- The user never receives the message
I believe this is fixable in some way as I was able to find a workaround with the Autofac container by actually replacing the default netcore service provider with Autofac.Extensions.DependencyInjection.ActofacServiceProvider.
I don’t know for sure, but I think what might be happening is that the Autofac extension might be wrapping service definitions in adapters instead of creating new service definitions for NSB so that any changes are made available. So if I’m correct about the implementation, then I think the fix would be to not copy service definitions but create adapters instead.
A bit more info in the issue I opened up a while ago including a repro and the autofac workaround described: https://github.com/aspnet/SignalR/issues/2347
I was able to verify that this is not a problem with SignalR but rather a problem with how libraries are interfacing with NSB’s IoC container. Autofac is an ok workaround at the moment, but I’d REALLY rather not being dealing with THREE different IoC containers, you know?