Ionic View and websockets


I’ve got a simple websocket test running (connecting to a node-Red instance) and it works fine on the desktop (ionic serve --lab).
However when I upload it to Ionic View it won’t connnect to the websocket.
I don’t think you can debug in Ionic View (or am I wrong). I don’t have a mac so can’t run an emulator for my iPhone.

Is this just an Ionic View thing or do I need to change something?

Here’s a snippet- the wsConnect() function is triggered by a button on the page. All works fine from the desktop.

  .controller('socket', function($scope){
        var server = "<local server address>";
        var topics ={topic:'topic/text'};
        var wsUriC = "ws://"+server+":1880/myApp";
        var ws;
        // used to show messages on webpage for debugging

        $scope.wsConnect = function (){
            console.log('running connect');
            $scope.detail.load ="connecting";
            ws = new WebSocket(wsUriC);
            ws.onopen = function(event){
                console.log('connection open ');
                $scope.announce = "Connected";
                $scope.send("hello from the browser");
            ws.onclose = function(event){
                console.log('connection closed');
                setTimeout(wsConnect, 1000);
            } of code here.

Thanks for any help



I’m having a similar issue. When I started my app on Ionic View, it was instantiating a new socket instance every 5 seconds.

When I uploaded the app to my iPhone and the issue resolved itself. Is there something about the Ionic View App that hinders websockets?



Sadly im getting the same problem using socket io


Same problem reproduces in Ionic 2 applications using Makes Ionic View unusable with socket connections. Response to this thread would be nice. It’s also impossible to debug, good improvement would be access to the console to atleast see error handling responses…