Deeper SignalR Integration
I'd like to see a deeper integration between ServiceStack and SignalR. Here are a few ideas that I've so far ran into...
A Hub Authorization Attribute which implements IAuthorizeHubConnection and/or IAuthorizeHubMethodInvocation.
Some sort of JsonServiceClient integration with HubConnections. Maybe automatically associating Cookies with a new HubConnection. Plus exception handling wrappers (i.e. Like an Unauthorized exception is thrown within a SignalR exception).
Centralized documentation outlining what needs to be changed in the web.config for SignalR to co-exist with ServiceStack. Also why the UseBufferedStream property should be enabled for SignalR.
This might require a separate feature request but an updated example app showing SignalR 2.0 integrated with ServiceStack 4.x. Only Examples I've seen have been with SignalR 1.x

The way ServiceStack and SignalR will be able to integrate in future will be through .NET Core’s IApplicationBuilder pipeline which by design supports running multiple frameworks within the same App that can now share the same default route namespace.
From the v4.5.2, ServiceStack now supports running on .NET Core, please see the guide in the full release notes which shows how to register ServiceStack’s AppHost in .NET Core: http://docs.servicestack.net/releases/v4.5.2.html
SignalR for .NET Core has yet to be released but it’s expected you’ll be able to access SignalR via its dependencies registered in .NET Core’s Startup which will also be injected in your Services like normal IOC dependencies.
We’ll update this feature request again with an example showing a demo of ServiceStack + SignalR together in the same App once SignalR is available on .NET Core in 2017.
-
@Sam You can call ServiceStack Services via the Service Gateway (https://docs.servicestack.net/service-gateway) the same non ServiceStack Services:
var response = HostContext,AppHost.GetServiceGateway().Send(new MyRequest());
You would need to use SignalR's client to use SignalR. The C# ServiceClients are only for calling ServiceStack Services, likewise the C# ServerEventsClient is for consuming ServiceStack's Server Events.
-
Sam Bosell commented
Now that SignalR has officially release, https://docs.microsoft.com/en-us/aspnet/core/signalr/introduction?view=aspnetcore-2.2
Do you plan on adding some examples and/or documentation on how to best integrate it into service stack. It would be awesome if the jsonclient got support for it with the backend.
-
Rob Vermeulen commented
Is there a working implementation for this yet? I am running into a lot of problems ("user ID required", routing issues etc..) when combining SignalR and ServiceStack in .NET core.
-
The integrated ServiceStack solution for real-time events is to use Server Events.
But if preferred you can happily configure SignalR in the same .NET Core App as ServiceStack, neither framework has dependencies or knowledge of each other but they both have access to the same dependencies registered in .NET Core's IServiceCollection.
-
Sam Bosell commented
Out of curiosity is there any movement on this?
-
Johan Mulder commented
This is awesome news ! Luv the idea that Rest api , signalr and server sent events can be fully integrated in SS. What will be absolutely awesome is Rest , SignalR , SSE and Akka.net
That will put SS on a different planet ;) -
Anonymous commented
Note that authenticated SSE isn't supported in IE9 and earlier browsers. In other browsers that don't support XmlHttpRequest to send http cookies and/or custom headers it cannot be implemented either.
Sadly to say, for this reason we are forced to leave SSE toward SignalR. -
Jonas Bohlin commented
We're using SignalR and we're seriously considering moving to ServiceStack for our api v2. But we'd like to keep using signalr for some operations, and here's why:
Server Sent Events are virtually unusable if you're serving content to iOS-devices. iOS only allows a small number of concurrent connections to any server, and an SSE endpoint blocks one of those connections, resulting in other requests not being allowed through. WebSockets doesn't cause this, on the other hand. -
Johann Klemmack commented
I've completed an initial typed C# client implementation at https://github.com/jklemmack/ServerSentEvents4ServiceStack. This repo also has a lighter-weight server implementation, where the "data" elements are raw DTOs, and the "event" field is used to govern the categorization of messages.
-
Apologies, I meant just SS's JS client bindings. The C# libraries have yet to be developed, I'll look at providing some integration with C# soon.
-
Ryan Britton commented
you mention in your comment that the SSE integration extends to the client libraries - how is this accessible, Demis? I can only see info for javascript clients....
-
Johann Klemmack commented
Any plans on a JsonServiceClient-based C# EventSource client?