Is it possible to use signalR with Service Fabric provided by Microsoft? I\'m trying to connect an UWP app and an angularJS app to my stateless reliable service hosted in an
You need to enable cross-domain setting for signalR to call it from other applications.
appBuilder.Map("/signalr", map =>
{
map.UseCors(CorsOptions.AllowAll);
var hubConfiguration = new HubConfiguration()
{
EnableJSONP = true,
EnableDetailedErrors = true,
EnableJavaScriptProxies = true
};
map.RunSignalR(hubConfiguration);
});
This code can be found in the readme.txt file we get after installing the Nuget package for the SignalR. For cross domain feature, you need to install the Cores nuget package also.
After deploying this application, you can see that some calls to signalR fails and Some succeeds. By default the instance count in Reliable stateless service is -1. Thus multiple instances will be created for the service.
From signaleR Connection.Start() method three SingalR APIs will be called. These calls should happen within the same session in-order to work it properly. When we call these three API in Service Fabric with multiple instances, the call might be processed in different nodes and thus different sessions which leads to failure in singalR connection.
One solution is to Make the instance count 1 for the stateless service fabric application. I don't think that this is an elegant solution.
You need to configure the load balancer to the client ip. Then the user will always get to the same node and other users to other nodes. The user to node relationship will be persistent.