1

我在使用 Lightstreamer 的 ionic1 应用程序时遇到问题。我试图将 LS 服务器连接到我的 4 个页面。因此,我尝试使用全局连接声明进行连接,并在具有新连接和连接共享的单个控制器中使用。我测试时它在浏览器中工作。但是当我签入真实设备时不起作用。在我的 index.html 文件中

<script>
    var protocolToUse = document.location.protocol != "file:" ? document.location.protocol : "http:";
        var portToUse = document.location.protocol == "https:" ? "443" : "8080";
        var lsClient = new Lightstreamer.LightstreamerClient(protocolToUse+"//domain.com:"+portToUse,"STOCKLIST_REMOTE");
        lsClient.enableSharing(new Lightstreamer.ConnectionSharing("MYCommonConnection", "ATTACH", "CREATE"));
        lsClient.connect();
</script>

在我的所有 4 个控制器中,我添加了如下代码

var protocolToUse = document.location.protocol != "file:" ? document.location.protocol : "http:";
var portToUse = document.location.protocol == "https:" ? "443" : "8080";
var lsClient = new Lightstreamer.LightstreamerClient(protocolToUse+"//domain.com:"+portToUse,"STOCKLIST_REMOTE");
lsClient.enableSharing(new Lightstreamer.ConnectionSharing("MYCommonConnection", "ATTACH", "CREATE"));
lsClient.addListener({
    onStatusChange: function(newStatus) {
      //update the connection status on the UI
     console.log(newStatus);
     if(newStatus == "CONNECTED:HTTP-STREAMING"){
        $scope.checkinternet    = false;
     }else if(newStatus == 'DISCONNECTED:WILL-RETRY'){
         $scope.checkinternet   = true;
     }
    }
  });

此代码在我的浏览器中运行良好,无需连接和会话终止。但没有在设备中工作。在得到 LS 服务器人员的一些建议后,我尝试了如下方式,

 var lsClient = new Lightstreamer.LightstreamerClient(protocolToUse+"//domain.com:"+portToUse,"STOCKLIST_REMOTE");
    lsClient.connect();

和 lsClient.disconnect() 用于每次导航。但是,如果我浏览页面 3 次,则连接会终止并且连接状态会显示为 DISCONNECTED:WILL-RETRY。为此,我向 LS 服务器支持项目寻求帮助,他们说 ionic 可能有有限的连接池。离子中是否有任何连接限制,我是否需要覆盖离子中的连接限制。有人可以帮我解决这个问题吗?

4

0 回答 0