繁体   English   中英

SignalR无法用于远程连接

[英]SignalR not working for remote connections

我在一个使用signalr的站点上工作,当我在本地计算机上对其进行测试时,它工作正常,但是当ai远程尝试它时,我无法浏览mvc,并且当我尝试向Signalar发送请求时,它就坐在那儿等待。

这是我的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
    });

};
}

这是信号中心:

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;
    }
}

并将其添加到我的web.config

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

我发现了问题所在。 我在自己的个人计算机上进行了测试,并且iis限制了并发连接的最大数量为3。因此,我在Windows服务器上运行了它,并且工作正常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM