Interfacing with SignalR

Introduction

Continuing from the previous blog comparing Diffusion with SignalR this blog will show how Diffusion can enhance the real-time experience of an application that uses SignalR and build a powerful application that is scalable, efficient, and reliable.

Integrating Diffusion With SignalR

The benefits of integrating Diffusion with SignalR are:

 

  1. Diffusion can manage the data being streamed from SignalR and handle the complexities of data synchronization and consistency across multiple clients.

  2. High-frequency data updates can lead to backpressure occurring if the consumer is slower than the producer. Diffusion can manage the flow of data so that clients receive updates at a manageable rate.

  3. Diffusion’s delta streaming feature can be used in conjunction with SignalR to optimize bandwidth usage and improve the performance of real-time data transmission.

  4. Whereas SignalR offers basic reconnection ability Diffusion provides multiple reconnection strategies giving the user more control.

  5. Scaling SignalR is challenging (see below) but Diffusion scales more easily.

Scalability

When comparing Diffusion and SignalR in terms of subscriber scalability, there are some key points to consider:

 

  1. Diffusion is designed to efficiently distribute data by sending only the data that is required to subscribers, rather than sending everything. It categorizes and splits data into a hierarchical topic tree.

  2. Diffusion’s delta streaming involves only the changes (deltas) between the old and new values of a topic being sent to the client which then reconstructs the full value.

  3. Diffusion can thus scale well with many subscribers because less data is transmitted, reducing server load.

  4. Adding an edge layer (https://www.diffusiondata.com/benchmarking-and-scaling-subscribers/) of Diffusion servers allows for linear scaling of clients far in excess of what is available on a single server.

Scaling out SignalR can be achieved using either the Redis backplane (for on-prem apps) or Azure SignalR service. However,

 

  1. SignalR does not support delta compression.
  2. SignalR can face challenges when scaling due to the persistent nature of its connections. SignalR requires sticky sessions and careful management of TCP connections. This can become a bottleneck in high-traffic scenarios. It must be pointed out that sticky sessions are not required if all clients are configured to only use WebSockets, and the SkipNegotiation setting is enabled in the client configuration.
  3. Azure SignalR service has limitations including downtime, expense and the company is restricted to using Azure (not AWS or GCP).

Thus Diffusion scales more easily than SignalR.

Diffusion Adapters

Diffusion is integrated with SignalR using an adapter. A Diffusion adapter is a component used with the Diffusion real-time data platform. These adapters facilitate the movement of real-time data from external sources into the Diffusion platform, making it easier to integrate and manage data flows within applications.

The adapters can be monitored and managed through the Diffusion Management Console, and they support various operations like ‘Pause’, ‘Resume’, and ‘Shutdown’. They are designed to work within a network, visible in the console’s ‘Network’ tab once started.

Adapters are written in Java (https://download.diffusiondata.com/gateway-framework/latest/user-guide/contents/writing-a-gateway-application/overview.html).

Solution Implementation

 

  1. The Diffusion adapter uses a streaming source handler to connect to the SignalR hub and subscribe to its data stream.

  2. The adapter then receives data in real-time from the SignalR hub.

  3. Each chunk of data the adapter receives is converted to json format using a payload converter and then published to the Diffusion server.

  4. Clients that subscribe to Diffusion receive updates in real-time.

This is illustrated in the diagram below:

Example

 

The code snippets below demonstrate the solution for the use case where stock data is sent by a SignalR application to subscribers using Diffusion:

 

  1. The adapter is shown below subscribing to stock data streamed from the SignalR hub when it starts up. To write an adapter please see the user guide of the Gateway Framework.

    @Override  
    public CompletableFuture<?> start() { 
        StartStreaming(); 
    }  

    private void StartStreaming() {  
        hubConnection.send("OpenMarket");  
        hubConnection.stream(Object.class, "StreamStocks")  
                .subscribe(  
                        (obj) -> {  
                            update(obj);  
                        },  
                        (error) -> {LOG.error(error.toString());},  
                        () -> {LOG.info("Completed");});  }

 

  1. On receiving stock data the adapter publishes to the Diffusion server for topic path ‘streaming/stock-data’.

     private void update(Object data) {  
         try {  
             publisher  
                 .publish("streaming/stock-data", data)  
                 .whenComplete((result, ex) -> { 
                     if (ex != null) {  
                         LOG.error("Failed to publish to topic {}",  
                             diffusionTopicName, ex);  
                     }  
                     else {  
                        LOG.debug("Published to server");  
                     }  
                  }); 
            }  
            catch(PayloadConversionException ex){ 
 
            }

 

3. A subscriber client receives the data in real-time and reports on required information.

     controlSession.feature(Topics.class)  
           .addStream("streaming/stock-data", 
                    JSON.class, 
                    new Topics.ValueStream.Default<JSON>() {  
              @Override  
               public void onValue(  
               String topicPath,  TopicSpecification specification,  
               JSON oldValue,  JSON newValue) {  
                   ObjectMapper mapper = new ObjectMapper();  
                   Map<String, Object> map = null;  

                    try {  
                        map = mapper.readValue(newValue.toJsonString(), Map.class);  
                    } catch (IOException e) {  
                        throw new RuntimeException(e); 
                    }  
                    LOG.info(  
                        map.get("symbol") + " " +  
                        map.get("price") + " (" +  
                        map.get("change") + ")");  }

 

Summary

Combining Diffusion with SignalR brings many benefits that include:

  • Diffusion can manage the data being streamed from SignalR and handle the complexities of data synchronization and consistency across multiple clients.

  • Diffusion’s delta streaming feature can be used in conjunction with SignalR to optimize bandwidth usage and improve the performance of real-time data transmission.

  • Diffusion is more easily scalable than SignalR in terms of handling a large number of subscribers due to its efficient data transmission model.

In conclusion, Diffusion and SignalR together make robust real-time data systems that are reliable and can handle complex scenarios.

Disclaimer: This blog was created based on documentation and resources freely available online about SignalR. The content was last updated on 27 Nov 2025. Be sure to double-check everything before you make any decisions. If you do find anything incorrect or out of date, then please let us know.


Further reading

BLOG

3 Common Misconceptions About Scaling Real-Time Infrastructure

June 05, 2025

Read More about 3 Common Misconceptions About Scaling Real-Time Infrastructure/span>

BLOG

How to use the Diffusion MCP Server

December 12, 2025

Read More about How to use the Diffusion MCP Server/span>

BLOG

Why Subscription-Based Data Models Are Reshaping Real-Time Architecture

June 13, 2025

Read More about Why Subscription-Based Data Models Are Reshaping Real-Time Architecture/span>

The owner of this website has made a commitment to accessibility and inclusion, please report any problems that you encounter using the contact form on this website. This site uses the WP ADA Compliance Check plugin to enhance accessibility.