Skip Navigation
Show nav
Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
    • .NET
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log inorSign up
View categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Developer Tools
    • Command Line
    • Heroku VS Code Extension
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery & Integration (Heroku Flow)
    • Continuous Integration
  • Language Support
    • Node.js
      • Troubleshooting Node.js Apps
      • Working with Node.js
      • Node.js Behavior in Heroku
    • Ruby
      • Rails Support
      • Working with Bundler
      • Working with Ruby
      • Ruby Behavior in Heroku
      • Troubleshooting Ruby Apps
    • Python
      • Working with Python
      • Background Jobs in Python
      • Python Behavior in Heroku
      • Working with Django
    • Java
      • Java Behavior in Heroku
      • Working with Java
      • Working with Maven
      • Working with Spring Boot
      • Troubleshooting Java Apps
    • PHP
      • PHP Behavior in Heroku
      • Working with PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
    • .NET
      • Working with .NET
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
      • Migrating to Heroku Postgres
    • Heroku Key-Value Store
    • Apache Kafka on Heroku
    • Other Data Stores
  • AI
    • Model Context Protocol
    • Vector Database
    • Working with AI
    • Heroku Inference
      • Inference Essentials
      • AI Models
      • Inference API
      • Heroku Inference Quick Start Guides
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
      • Single Sign-on (SSO)
    • Private Spaces
      • Infrastructure Networking
    • Compliance
  • Heroku Enterprise
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
  • Language Support
  • .NET
  • Working with .NET
  • Scaling ASP.NET Core SignalR Apps on Heroku

Scaling ASP.NET Core SignalR Apps on Heroku

Last updated June 16, 2025

Table of Contents

  • Connection Routing
  • Message Coordination
  • Summary
  • Additional Reading

Deploying ASP.NET Core SignalR applications on Heroku requires minimal setup. However, scaling SignalR apps to multiple dynos requires you to configure:

  1. Connection Routing: Keep client connections stable in Heroku’s stateless routing environment.
  2. Message Coordination: Share messages across dynos to reach all connected clients.

Connection Routing

By default, SignalR clients connect through a transport negotiation process that involves multiple HTTP requests. Heroku’s router is stateless by default, so each request can go to any available web dyno. Client connections can break when a request reaches a dyno that doesn’t have the client’s session state from previous requests.

You can resolve this issue with WebSockets (recommended) or Session Affinity.

Manage Connection Routing With WebSockets

We recommend you use WebSockets as it’s the most reliable solution for both clients and servers. WebSockets eliminate transport negotiation and work well with Heroku’s stateless router. To learn more, see WebSockets on Heroku.

Using WebSockets means you lose SignalR’s automatic transport fallback. However, because all modern browsers and clients support WebSockets, we recommend it as it’s often the most reliable approach.

Client Configuration: Skip Transport Negotiation in Your Client Code

const connection = new signalR.HubConnectionBuilder()
    .withUrl("/noteHub", {
        skipNegotiation: true,
        transport: signalR.HttpTransportType.WebSockets
    })
    .build();

Server Configuration: Enforce WebSocket-Only connections

app.MapHub<YourApp.NoteHub>("/noteHub", options =>
{
    options.Transports =
        Microsoft.AspNetCore.Http.Connections.HttpTransportType.WebSockets;
});

Manage Connection Routing With Session Affinity

Without WebSockets, SignalR uses HTTP-based transports like Long Polling. Long Polling requires multiple requests to maintain a real-time connection.

If you need to support clients that can’t use WebSockets, you can use Heroku’s session affinity feature. Session affinity is only available for apps on the Common Runtime. To learn more, see Session Affinity.

To enable session affinity, run:

$ heroku features:enable http-session-affinity

Message Coordination

In a multi-dyno environment, you also need a backplane to share messages between servers. Setting up a backplane ensures messages from any dyno reach all relevant clients.

To learn more about scaling with backplanes, see Microsoft’s SignalR Scaling documentation.

Set Up a Redis Backplane

You can set up a Redis backplane with the Heroku Key-Value Store add-on:

  1. Add the Heroku Key-Value Store add-on:

    $ heroku addons:create heroku-redis:mini
    
  2. Install the SignalR Redis package:

    $ dotnet add package Microsoft.AspNetCore.SignalR.StackExchangeRedis
    
  3. Configure the backplane for SignalR:

    // Program.cs
    // ...
    using StackExchange.Redis;
    
    var builder = WebApplication.CreateBuilder(args);
    
    var redisUrl = Environment.GetEnvironmentVariable("REDIS_URL");
    if (!string.IsNullOrEmpty(redisUrl))
    {
        // Parse the Redis URL for our client
        var uri = new Uri(redisUrl);
        var userInfoParts = uri.UserInfo.Split(':');
        if (userInfoParts.Length != 2)
        {
            throw new InvalidOperationException("REDIS_URL is not in the expected format ('redis://user:password@host:port')");
        }
    
        var configurationOptions = new ConfigurationOptions
        {
            EndPoints = { { uri.Host, uri.Port } },
            Password = userInfoParts[1],
            Ssl = true,
        };
    
        // Handle Heroku's self-signed certificates
        // See: https://devcenter.heroku.com/articles/heroku-redis#security-and-compliance
        configurationOptions.CertificateValidation += (sender, cert, chain, errors) => true;
    
        // Set up the SignalR backplane
        builder.Services.AddSignalR().AddStackExchangeRedis(options =>
        {
            options.Configuration = configurationOptions;
            options.Configuration.ChannelPrefix = "YourAppName";
        });
    }
    else
    {
        // Local development fallback
        builder.Services.AddSignalR();
    }
    
    var app = builder.Build();
    
    // ...
    app.Run();
    

To learn more about connecting your .NET app, see our Heroku Key-Value Store docs.

Summary

To successfully scale a SignalR app on Heroku:

  • Single dyno: No special configuration needed.

  • Multiple dynos require:

    • A WebSockets-only configuration on both client and server (recommended) or Session Affinity.
    • A Redis backplane configured with Heroku Key-Value Store.

Additional Reading

  • Heroku .NET Support
  • Session Affinity
  • Heroku Key-Value Store

Keep reading

  • Working with .NET

Feedback

Log in to submit feedback.

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure
  • .NET

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Github
  • LinkedIn
  • © 2025 Salesforce, Inc. All rights reserved. Various trademarks held by their respective owners. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States
  • heroku.com
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Contact
  • Cookie Preferences
  • Your Privacy Choices