Last post Aug 24, 2015 02:12 PM by CheongSin
Aug 21, 2015 03:48 PM|CheongSin|LINK
I have setup self-hosted Owin worker-role to host Signalr using persistentConnection model.
I have several clients connected to the signalr server at any give time. I also have webapi being hosted in a separate work-role.
whenever a certain webapi is called, i need to send a notification to all the clients. So, i have setup another client from webapi worker-role that will connect to signalr server during the initialization of the worker-role and stayed connected so i
don't have to issue connect every time i send notification. The problem with this approach is that sometimes the client's connection from webapi drops and it never gets recovered. If that client is down then, i cannot send any notification. I've
tried everything. when onClosed or onDisconnect is fired, try to reestablish connection, etc... It doesn't work up to my satisfaction.
So, i am wondering if there's a way to send certain msg to all the clients connected to a signalr server without using a dedicate client from webapi.
I've looked at this piece of code,
public class Notifier
public static void GroupNotify(string group, string message)
var context = GlobalHost.ConnectionManager.GetConnectionContext<MyEndPoint>();
}But MyEndPoint can only be recognized where signalr is being hosted, WebApi workerRole knows nothing about MyEndPoint class...I thought MyEndPoint can be just a string, a URL for signalr endpoint, but it's not. Am i missing something here??any thought?thanks.
Aug 24, 2015 01:53 AM|Li Wang|LINK
Thank you for your post. According to your description, your goal is send a notification to all the clients when a certain webapi is called, Am I right? The api application and SignalR applicaiton are run in different application domain/process.
So when a certain webapi is called, webapi application have to notification the Signalr applicaiton.
Inter-process communication technologies you could use to fix it. You create a service in Signalr applicaiton for webapi to invoke. In the service you could do the notification to all clients.
Code sample in Signalr application.
public class MyHub : Hub
public void NotificationAllClients()
Code sample in Api application.
Aug 24, 2015 02:12 PM|CheongSin|LINK
Thanks for the reply. But that's not my problem. my problem is having the proxy client to stay connected all the time and I sometime loose the connectivity. If that happens, i have to reboot the instances to have that client connect to signalR again.
I like to know if there's a way to send notification to clients(recipients) without a dedicate proxy client(sender).
by the way, i am using persistent connection over hub at this moment.