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.detail={};
$scope.detail.load="waiting";
$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);
}
...rest of code here.
Thanks for any help
Shane