Hi,
this is not really an ionic question, but more likely a web socket question for mobiles.
I am using angular-websockets (https://github.com/angular-class/angular-websocket) to implement a web socket client in my app (iOS and Android). The problem I am facing is I can see the web socket being initialized and when I am running my app and I bring down the web socket server, I see my app trying to reconnect, so I know the socket is alive, but when the server is sending any message (I am sending “test” every 5 seconds from the server) my onMessage callback is never called. I know the server works because I am running a web socket client in Chrome as well and it receives it, but not my app.
Can someone tell me if they see something wrong in my app code:
angular.module('zmApp.controllers').service('EventServer',
[ '$websocket', 'ZMDataModel', '$rootScope',function
( $websocket, ZMDataModel, $rootScope) {
ZMDataModel.zmLog("*************EVENT SERVER*************");
var dataStream;
var loginData = ZMDataModel.getLogin();
ZMDataModel.zmLog ("webSocketStart: attempting to start a WSS connection");
dataStream = $websocket( "wss://<server name removed>", {reconnectIfNotNormalClose: true});
dataStream.onMessage(function(message) {
ZMDataModel.zmLog("GOT WEBSOCKET MESSAGE:" + JSON.parse(message.data));
});
dataStream.onError(function(message) {
ZMDataModel.zmLog("GOT WEBSOCKET ERROR:" + JSON.parse(message.data));
});
/* dataStream.onClose(function(message) {
ZMDataModel.zmLog("GOT CLOSE:" + JSON.parse(message.data));
});*/
}]);