signalr
  1. signalr-backplane-providers-redis-azure-service-bus

Backplane Providers (Redis/Azure Service Bus) - Scale-out with SignalR

Syntax

public void ConfigureSignalR(IAppBuilder app)
{
    string backplaneConnectionString = "<backplaneConnectionString>";
    GlobalHost.DependencyResolver.UseRedis(backplaneConnectionString);
    app.UseAzureServiceBusBackplane("<serviceBusConnectionString>");
    app.MapSignalR();
}

Example

public void ConfigureSignalR(IAppBuilder app)
{
    string backplaneConnectionString = "redis-1234567.redis.cache.windows.net:6380,password=myPassword,ssl=True,abortConnect=False";
    GlobalHost.DependencyResolver.UseRedis(backplaneConnectionString);
    app.UseAzureServiceBusBackplane("Endpoint=sb://my-servicebus.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=mySharedAccessKey");
    app.MapSignalR();
}

Output

A SignalR application with backplane providers Redis and Azure Service Bus for scale-out.

Explanation

In a SignalR application, backplane providers are used to synchronize messages across different instances of the application, allowing scaling out and high availability. Redis and Azure Service Bus are two popular options for backplane providers.

This code example demonstrates how to configure SignalR to use both Redis and Azure Service Bus as backplane providers for scale-out. The connection strings for the providers are provided as parameters to the configuration methods.

The GlobalHost.DependencyResolver.UseRedis method is used to configure Redis as a backplane provider. The method takes the connection string for the Redis server as a parameter.

The app.UseAzureServiceBusBackplane method is used to configure Azure Service Bus as a backplane provider. The method takes the connection string for the Service Bus namespace as a parameter.

Finally, the app.MapSignalR method is called to map the SignalR hub to the application.

Use

Use this code example to configure SignalR to use Redis and Azure Service Bus as backplane providers for scale-out in a .NET application.

Important Points

  • Redis and Azure Service Bus are popular backplane providers for SignalR.
  • The GlobalHost.DependencyResolver.UseRedis method configures Redis as a backplane provider.
  • The app.UseAzureServiceBusBackplane method configures Azure Service Bus as a backplane provider.
  • The connection strings for Redis and Azure Service Bus are provided as parameters to the configuration methods.
  • The app.MapSignalR method maps the SignalR hub to the application.

Summary

This code example demonstrates how to configure SignalR to use Redis and Azure Service Bus as backplane providers for scale-out in a .NET application. The connection strings for both providers are provided as parameters to the configuration methods.

Published on: