Saturday, February 23, 2013

SignalR: Using a Hub instance not created by the HubPipeline is unsupported

When you need to push data to a SignalR hub from outside the hub (from a Controller for example), don't try to create a new instance of the Hub, like I did. Otherwise you'll see this nice exception:

"Using a Hub instance not created by the HubPipeline is unsupported"

From Microsoft.AspNet.SignalR.Core

Instead, the hub context must be retrieved:

var context = GlobalHost.ConnectionManager.GetHubContext<HubType>();
context.Clients.All.Whatever();

4 comments:

  1. Hello, The problem is that you can't target the Caller using this solution. Any help ?

    ReplyDelete
  2. http://www.asp.net/signalr/overview/signalr-1x/getting-started/introduction-to-signalr

    ReplyDelete