SignalR Messaging Overview: A Look at How It All Hangs Together

A flow-chart representing the route a SignalR message takes through a standard SignalR implementation. A client browser is on the left, with a group called "MVC App" containing a Request Handler and ChatHubInstance. The flow goes starts with the request handler mapping the ChatHubInstance to the endpoint /ChatHubEndpoint. The client then connects to the SignalR hub using the defined endpoint and transmits a "SendChatMessage" message to the hub endpoint, which is translated into an actual procedure called SendChatMessage on the mapped hub. The SendChatMessage procedure then sends a "ReceiveChatMessage" message to all clients, which each invoke their "ReceiveChatMessage" handler on receipt.

SignalR is a fantastic library for enabling real-time applications, especially when using MVC or Blazor in ASP.NET Core. I’ve been using it a lot lately and while it is an excellent way to make your application feel super responsive through messaging and remote procedure calls, there are certain aspects of how the whole thing hangs together which can be very confusing.

This blog post is designed to give you an overview of the different parts of a “standard” SignalR implementation and explain how messages flow through the system. I won’t be going into details on how SignalR works internally (if I even could!), instead choosing to focus on the parts that you’ll come into direct contact with. This blog post also isn’t designed as a tutorial since there is great documentation for implementing SignalR already (which is where I sourced the below code examples from!).

Continue reading “SignalR Messaging Overview: A Look at How It All Hangs Together”