Microsoft developers have released the SignalR service SDK with Asp.Net support. In this post, we shall discuss about the latest MS Azure SignalR version 1.0.0 and its preview.
Azure SignalR service is intended for real-time messaging. Developers can now scale Asp.net Core SignalR applications using this way. However, the service is designed on SignalR for ASP.NET core 2.0, which is not completely compatible with SignalR service. Developers need to make changes to code to make ASP.NET SignalR app compatible with SignalR service. Moreover, the service SDK needs to add support of ASP.NET.
Architecture used for Asp.net Support
Fig – Showing the typical architecture to use Azure SignalR Service with an app server in Asp.net core or ASP.NET
The app server listens to client’s connection requests and handles connections in self-hosted SignalR app. Using SignalR service support, the same server only replies to negotiate requests made by clients and redirects clients to SignalR service to create a persistent client-server link.
Things ASP.Net Development Services provider can do with Asp.net support for the Azure SignalR service:
- They can continue to keep SignalR app in Asp.net and work with fully owned and managed SignalR service
- They just need to make few changes to the SignalR API code to switch to use SignalR service.
- They can leverage built-in features of Azure SignalR service and tools to help run SignalR app with assured SLA.
Asp.net SignalR is an open source library that helps ASP.NET developers in adding real-time web functionality to web apps. Real time web functionality enables developers to have server-side code push content to the clients that are connected, on spot, in real time.
Azure SignalR Service Use Cases
There are numerous types of apps that need real time content updates. Here are some use cases for using Azure SignalR service-
- Apps such as gaming, voting, maps, auction, GPS apps that need high frequency updates through the server
- Dashboards and monitoring apps like instant sales updates
- Collaborative purpose apps like whiteboard apps, team meeting software, etc.
- Apps with notifications, like social networking, chat, travel alerts, games, etc.
Some features and APIs called off by the support-
- Forever Frame Transport
- Automatic Reconnects
- HubState
- GlobalHost Object
- PersistentConnection Class
- HubPipeline module
- Client-side internet explorer support prior MS internet explorer 11
Today’s apps provide latest information without any need of refreshing the page. You can add real-time functionality to your dashboards, games, maps, etc.
Many businesses require real-time updates on the application. Let’s take an example of a trading application. So, the data inside this type of application needs to be updated frequently and quickly without refreshing the page or screen. For building such types of real-time applications, ASP.NET is highly used. You can hire dedicated net developers to make applications that require quick updates in real-time.
The support of ASP.NET emphasizes on compatibility, which results in zero support for all new features from Asp.net core SignalR. For instance, features like Streaming is only available for apps with Asp.net Core SignalR support.
SignalR is a kind of technology that has feature to push new emails to your account as soon as they arrive. With SingalR service, you get a complete managed service that assists you build real-time experiences.
Real time web functionality
Since SignalR is designed on ASP.NET core, and the “hubs” are the part of its architecture. Hubs run over your server and route messages in and out to ensure that they get received by the intended recipient in real time. When you create a hub in your middleware, the two pieces of code present at the moment tie everything together.
The initial method is AddSignalR, which you call in your Startup.ConfigureServices method of web app to allow passing of SignalR messages to SignalR.
The next method is UseSignalR, which is placed inside your Startup.Configure method of web app. This generates awareness about your hub among SignalR.
Both the methods are significant when you move your SignalR app to Azure SignalR service. It’s not as complicated as provisioning the infrastructure yourself.
Developers can establish SignalR connection in three ways – Server-Sent events, websocket, and long polling. Websocket is the only transport that offers real duplex interaction while the remaining two are just following it. However, there are platforms that don’t support websockets and for them, SignalR will automatically try to use distinct kind of communication. It can also be forced communication.
Single connection to server can go to just single Hub- it means if you are using a server with multiple hubs; your client will have to create multiple connections to each hub separately. Linked client can use any public method defined within hub. Simultaneously, server can use any method that client is listening to it. Hub also reveals Context Property where it tracks information like active connections.
When the connection between client and hub gets established, hub gets its unique id. The client has facility to join a virtual group- collection of clients. When he joins a group that doesn’t exist yet, then the server automatically creates that group. The server can even send messages to clients in three ways-
- Broadcast to every client that is connected to hub
- Send messages to clients within a group only
- Send a single text to a specific client
Asp.net core authentication mechanics are supported by SignalR server. Authorize attributes can be rolled over entire hub classes or on certain methods. It works similarly as in ASP.NET core app.