Search code examples
signalrsignalr-hubasp.net-core-signalrazure-signalr

Is it possible to use SignalR on Azure to communicate between .Net Core and MVC5?


I have an AzureSignalR instance created and 2 client apps. One is an MVC5, .Net 4.7.2 app and the other a .Net Core 2.2. I've create an identical SignalR Hub in both that is simply

    public class MessageHub : Hub
    {
        public void Send(ApplicationEvent evt)
        {
            // broadcastMessage must be a javascript method on the client
            Clients.All.broadcastMessage(evt);
        }
    }

and implemented the necessary javascript on both. The problem I have is that while messages can be sent and received by each of the apps separately, they do not receive messages raised by the other.

I can see a slight difference in the request to the AzureSignalR service in that the values in the asrs.op parameter are different i.e.

MVC5

https://<redacted>.service.signalr.net/aspnetclient/negotiate?clientProtocol=2.1&_=1572008814078&asrs_request_id=1tgsLXwGAAA%3D&asrs.op=%2Fsignalr&connectionData=%5B%7B%22name%22%3A%22messagehub%22%7D%5D

.Net Core

https://<redacted>.service.signalr.net/client/negotiate?hub=messagehub&asrs.op=%2Fmessagehub&asrs_request_id=NmhXZHcGAAA%3D

and wondered if this was the reason, but I can't see a way to change the MVC5 op name as it is inferred.

Obviously we'll be upgrading the MVC5 app at some stage, so this would be ideal in the interim.


Solution

  • You are using two different types of SignalR here. One is the new one for .NET Core an other is old SignalR for .NET Framework applications. You can see the differences between both on this microsoft documentation.

    Since those are two different implementations of SignalR, it is the reason why they don't communicate with each other. Azure SignalR is more for helping you scale out your SignalR instances and don't bother with sticky sessions, Redis backplane configurations and other infrastructural stuff.

    enter image description here