1

In an ASP.NET Web Form application, we are using Microsoft.AspNet.SignalR to update the progress of some long-running Task, its all working fine with local IIS server but it's not working when hosted in IIS behind load balancer (Barracuda) Here is the Hub Code

  public static void SendProgress(string progressMessage, int progressCount, int totalItems,bool isInitializing)
        {
            //IN ORDER TO INVOKE SIGNALR FUNCTIONALITY DIRECTLY FROM SERVER SIDE WE MUST USE THIS
            var hubContext = GlobalHost.ConnectionManager.GetHubContext<ProgressHub>();
            var percentage =0.0;
            //CALCULATING PERCENTAGE BASED ON THE PARAMETERS SENT
            if (!isInitializing)
                percentage = ((double)(progressCount * 100) / (double)totalItems);

            if (Convert.ToDouble(percentage) > 100)
                percentage = 100;

            //PUSHING DATA TO ALL CLIENTS
            hubContext.Clients.All.AddProgress(progressMessage, Convert.ToDouble(percentage.ToString("N2")));
        }

Here is the Client-Side script

 $(document).ready(function () {
            var progress = jqry.connection.progressHub;
            console.log("Test!!!!!!");
            console.log(progress);
            //var intervalID = setInterval(updateProgress, 250);
            progress.client.addProgress = function (message, percentage) {
                //at this point server side had send message and percentage back to the client
                //and then we handle progress bar any way we want it
                //Using a function in Helper.js file we show modal and display text and percentage 
                updateProgress(percentage);
                console.log("Signal R PERCENTAGE " + percentage);
            };

            //Before doing anything with our hub we must start it
            jqry.connection.hub.start().done(function () {
                //getting the connection ID in case you want to display progress to the specific user
                //that started the process in the first place.            
                console.log("Signal R Done");
            });
        });

Initially Web socket was not enabled in load balancer so URL wws://www.example.com/signalR/ was giving 404 error but then we made changes to add

header
Upgrade: websocket
Connection: Upgrade

It's not giving the error and status is a success but it's not calling the Client-side function addProgress

We are not getting how to proceed on debugging the problem

Update When we directly call SignalR endpoint(through Internal IP without Baraccuda) still, it's not working, when we debug the web app

/Z1/signalr/negotiate?clientProtocol=1.5&connectionData= endpoint returns 200 OK response is

{"Url":"/Z1/signalr","ConnectionToken":"sometoken","KeepAliveTimeout":20.0,"DisconnectTimeout":30.0,"ConnectionTimeout":110.0,"TryWebSockets":true,"ProtocolVersion":"1.5","TransportConnectTimeout":5.0,"LongPollDelay":0.0}

/Z1/signalr/connect?transport=webSockets&clientProtocol=1.5&connectionToken= endpoint response returns 101 Switching Protocols

/Z1/signalr/start?transport=webSockets&clientProtocol=1.5&connectionToken= endpoint returns 200 OK response is { "Response": "started" }

Nithya
  • 582
  • 8
  • 19
  • I suggest you could firstly try to enable the web socket in the barracuda according to this [link](https://campus.barracuda.com/product/webapplicationfirewall/doc/49054741/how-to-enable-websocket/1) and try to run your application again. – Brando Zhang Jan 02 '20 at 02:35
  • Hi @BrandoZhang We enabled Web Socket in Barracuda the same way mentioned in the link – Nithya Jan 02 '20 at 06:07

0 Answers0