2014-03-19 51 views
1

我正在使用signalr的网站上工作,它工作正常,当我在本地机器上测试它时,但是当ai远程尝试时,我无法浏览mvc,而当我尝试发送请求时签署它只是坐在那里等待。SignalR不适用于远程连接

这里是我的javascript代码(我使用angularjs但所有的代码工作正常!):

function FixturesListController($scope,$q) { 

$scope.fixtures = ['']; 

var stringListHub = $.connection.stringListHub, 
    model = { 
     Items: [] 
    }; 
$.connection.hub.url = "http://192.168.1.2:8001/signalr"; 

stringListHub.client.updateModel = function(newName) { 
    if (newName.Items != null) { 
     $scope.$apply(function() { 
      $scope.fixtures.length = 0; 
      $(newName.Items).each(function(index, value) { 
       $scope.fixtures.push(value); 
      }); 
     }); 
    } 


} 

$.connection.hub.start({ xdomain: true }).done(function() { 
    var fixtures = stringListHub.server.test().done(function (item) { 
     $scope.$apply(function() { 
      if (item.Items != null) { 
       $scope.fixtures.length = 0; 
       $(item.Items).each(function(index, value) { 
        $scope.fixtures.push(value); 
       }); 
      } 
     }); 
    }); 

}); 

$scope.AddFixture = function() { 
    $scope.fixtures.push($scope.newName); 
    stringListHub.server.updateModel({ 
     Items: $scope.fixtures 
    }); 

}; 
} 

这里是signalr枢纽:

public class StringListHub : Hub 
{ 
    private static StringList _list = new StringList(); 

    public void UpdateModel(StringList model) 
    { 
     _list = model; 
     _list.LastUpdatedBy = Context.ConnectionId; 
     // Update the shape model within our broadcaster 
     Clients.AllExcept(_list.LastUpdatedBy).updateModel(_list); 
    } 

    public StringList Test() 
    { 
     return _list; 
    } 
} 

而且我添加到了我的网络.config

<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"> 
    </modules> 
</system.webServer> 
+0

“无法浏览MVC”,这是什么意思?你是否收到任何错误信息? – Steve

+0

您是否使用过Fiddler或Firebug之类的东西来查看是否有响应错误代码被发送回来或出现javacript错误? – Steve

+0

是的,尝试了所有的和cannont浏览mvc我的意思是它只是坐在那里加载和没有任何反应 –

回答

1

我发现问题是什么。我在我自己的个人机器上测试它,并且iis对并发连接的最大数量限制为3.所以我在windows服务器上运行它,并且它工作正常。