Action doesn't get fired on signalr hub when using websockets over load balancer, SSE or any other method works fine

Viewed 214

I have a signalr hub setup for a chat function using Signalr version 2.4.0. A SQL backplane is used and setup in the standard way as the site is across two servers using a cloud load balancer from Rackspace.

Using Server Sent Events there is no issue, messages are sent over the load balancer without a problem. When using websockets the onConnected and onDisconnected are called normally and a connection is made. I've enabled signalr logging on the browser and can see no errors or issues. However when a hub action is called from the browser i.e. hub.server.sendaction();, in this instance to send a message (although it applies to any action being fired other than connect or disconnect) nothing at all happens. The action doesn't get fired, there is no error anywhere it seems.

Taking the load balancer out of the equation seems to resolve the issue, the action is called and the message is sent to the other user.

Can anyone speculate as to what the problem here? I've enabled every form of logging I could come across and I can't see any errors or issues. According to the signalr logging a websocket connection is established normally. I can see in the log the hub action is being invoked correctly. Clearly the load balancer must be involved somehow but seeing as there is no issue with SSE and no errors I have no real idea as to why the action is not getting called?

Edit - As requested, this is the hub, contents of action not included as the action is simply not firing. There is an onConnected and onDisconnected method, both fire as normal:

namespace SignalRChat
{
    public class NotificationHub : Hub
    {
      private ApplicationDbContext db = new ApplicationDbContext();

      public void Send(int ChatID, string UserID, string message, string 
      name, string profileImage)
      {
          //Stuff happens here but it is not being fired at all
      }
    }
}

Relevant javascript on page:

$(function () {
var note = $.connection.notificationHub;
        $.connection.hub.logging = true;

$.connection.hub.start().done(function () {

            $(document).on("click", "#sendmessage", function () {
            note.server.send('@Model.ChatID', '@Model.UserID', $('#message').val(), '@Model.Name', '@Model.ProfileImage');
            msgArea.scrollTop = msgArea.scrollHeight;
            $('#message').val('').focus();
        });
$.connection.hub.qs = { 'name': '@Model.Name', 'UserID': '@Model.UserID', 'connectionGroup': '@Model.ChatID' + '_hub', 'cohortName': '@Model.Cohortname', 'outlog': 'in' };
});
0 Answers
Related