title: Signal R Connection Get 500 response On AWS ec2
body: <p>i have two applications</p>
  
  <ul>
  <li>Web api Core</li>
  <li>Web application Angularjs</li>
  </ul>
  
  <p>from web api app  i want to push notification to web app so iused </p>
  
  <pre><code>hubConnection = new HubConnection(_config["APIRoot:url"], useDefaultUrl: false);
     hub = hubConnection.CreateHubProxy("TaskHub");
  </code></pre>
  
  <p>to push a message for example to all clients ,
  it works fine on my local machine also i deployed my two app to a local server (windows) and it works fine </p>
  
  <p>note: local server links </p>
  
  <ul>
  <li>Web api Core(192.168.100.30:8080)</li>
  <li>Web application Angularjs(192.168.100.30:8181)</li>
  </ul>
  
  <p>then we deploy to aws ec2 server as beta server using (Kubernates) with following links :</p>
  
  <ul>
  <li>Web api Core(ms-qa.mycompany.com/api)</li>
  <li>Web application Angularjs(ms-qa.mycompany.com)</li>
  </ul>
  
  <p>i got the following error in console 
  <a href="https://i.stack.imgur.com/SC4FA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SC4FA.png" alt="enter image description here"></a></p>
  
  <p>but some times it working (not stable)</p>
  
  <p>iam using angular js factory in web app </p>
  
  <pre><code>BOAApp.factory('signalRService', ['$http', '$q', 'urlRoot', 'httpService', '$cookies',
  function ($http, $q, urlRoot, httpService, $cookies) {
      var hubConnection;
      var hub;
  
      var signalR = {
          hubStart: function () {                
              var token = "";
              var authData = $cookies.get('authorizationBOAAppData');            
             // hubConnection = $.hubConnection(urlRoot);
              hubConnection = $.hubConnection(urlRoot +"/signalr", {
                  useDefaultPath: false
              });
              hub = hubConnection.createHubProxy('taskHub');
              if (authData) {
                  authData = JSON.parse(authData);
                  token = authData.authInfo.token;//'Bearer ' +
              }
              hubConnection.qs = { 'auth_token': token };
              hubConnection.logging = true;
  
              var def = $q.defer();
              hubConnection.start({ withCredentials: false }).done(function () {
                 // hub.invoke('join');
                  console.log("Hub started");
                  def.resolve("hub started successfully started");
  
              }).fail(function (error) {
                  console.log(error);
                  def.reject("hub conniction faild to start");
              });
              //---- Connection Events -----//
              hub.connection.error(function (error) {
                  if (error)
                      console.log("An error occurred: " + error.message);
                  self.hub = null;
              });
              hub.connection.disconnected(function (error, callback) {
  
                  console.log("Connection lost. " + error);
  
                  // IMPORTANT: continuously try re-starting connection
                  setTimeout(function () {
                      hubConnection.start({ withCredentials: false }).done(function () {
                          //if (callback)
                          //    callback();
                      //    hub.invoke('join');
                          console.log("Hub started");
                      });
                      console.log("setTimeout Hub Connect");
                  }, 1000);
              });
              hub.connection.stateChanged(function (change) {
                  if (change.newState === $.signalR.connectionState.reconnecting) {
                      console.log('Re-connecting');
                  }
                  else if (change.newState === $.signalR.connectionState.connected) {
                      console.log('The server is online');
                  }
                  else if (change.newState === $.signalR.connectionState.connecting) {
                      console.log('The server is connecting');
                  } else if (change.newState === $.signalR.connectionState.disconnected) {
                      console.log('The server is disconnected');
                  }
              });
              //--- End Connection Events -//
              return def.promise;
          },
          state: function () {
              // connecting: 0, connected: 1, reconnecting: 2, disconnected: 4
              return hub.connection.state;
          },
          hubProxy: function() {
              return hub;
          },
          hubProxyConnection: function() {
             return hubConnection;
          }
      }
  
      return signalR;
  }]);
  </code></pre>
  
  <p>Any help would be appreciated!</p>