title: SignalR Client Authentication with Host
body: <p>I came here reaching for your help. I am fairly new when it comes to SignalR and after several days of reading and retrying stuff again and again I have reached a dead end. Straight to the point.
  I have a solution which includes several projects in it. The ones that are giving me trouble are the Web and a class library.
  I have SignalR installed in the Web project and the SignalR Client in the Class Library.
  My target is to track and monitor the progress of Long running processes that are running in the Class Library. I have SignalR working properly from the Web.
  This is my Hub method that I am trying to call: </p>
  
  <pre><code>public void SendProgress(string progressMessage, int progressCount, int totalItems)
      {
          var percentage = (progressCount * 100) / totalItems;
  
          Clients.All.sendProgress(progressMessage, percentage + "%");
      }
  </code></pre>
  
  <p>Moreover I have a method in the Class Library (ImportProcess) which contains a foreach loop. Inside that foreach loop I am calling:</p>
  
  <pre><code>public void SendProgress(string message, int currentItem, int totalItems)
  </code></pre>
  
  <p>The body of the SendProgress is this: </p>
  
  <pre><code>public void SendProgress(string message, int currentItem, int totalItems)
      {
          var hubConnection = new HubConnection("http://localhost:13310/");
          IHubProxy statementsHubProxy = hubConnection.CreateHubProxy("statementsHub");
          hubConnection.Credentials = CredentialCache.DefaultNetworkCredentials;
          hubConnection.Start().Wait();
  
          statementsHubProxy.Invoke("SendProgress", message, currentItem, totalItems);
  
      }
  </code></pre>
  
  <p>The problem is that since I am calling the SendProgress inside a foreach, I consider it wrong to define the connection everytime that SendProgress is called. 
  I tried including the Connection properties to the constructor of the class. It worked but it only returns the first iteration of the foreach and ignored all the others. </p>
  
  <p>I have to mention though, that if I have the connection properties inside the SendProgress method, the code works and I am receiving the information I want in the cosnole, but again, I think it shouldn't be like that.</p>
  
  <p>This is the MVC controller which calls a rest service which in turn calls the class library </p>
  
  <pre><code>public JsonResult AProcess()
      {
          _dataImportService.DataImportProcess("2018-02-27", "2018-02-28", "This is another parameter");
          return Json("", JsonRequestBehavior.AllowGet);
      }
  </code></pre>
  
  <p>Please ignore the parameters of the DataImportProcess as they are irrelevant at this point. </p>
  
  <p>This is my Startup.cs </p>
  
  <pre><code>public class Startup
  {
      public void Configuration(IAppBuilder app)
      {
          app.MapSignalR();
      }
  }
  </code></pre>
  
  <p>I am using SignalR 2.2.2</p>
  
  <p><strong>Edit #1</strong>
  I included the connection properties to the constructor of the class again like this: </p>
  
  <pre><code>static IHubProxy _proxy { get; set; }
      public ImportClass()
      {
          var hubConnection = new HubConnection("http://localhost:13310/");
          hubConnection.Credentials = CredentialCache.DefaultNetworkCredentials;
          IHubProxy statementsHubProxy = hubConnection.CreateHubProxy("statementsHub");
          _proxy = statementsHubProxy;
          hubConnection.Start().Wait();
      }
  </code></pre>
  
  <p>But no luck. SendProgress method is not sending any updates at all. </p>
  
  <p>Any help is much, much appreciated. 
  Best regards, 
  Konstantinos.</p>