I am developing an app in ionic
and I can't connect to the socket server when running on a device.
I have managed to connect my app (port:8100
) to a node server(port:9000
) locally when developing (via ionic serve
), I don have a cors issue, everything runs fine.
Client looks something like this :
socket = new io.connect('http://192.168.1.106:9000');
socket.on('reconnect_attempt',function() {
alert('crap');
});
P.S: the above code is from my own memory, but I know I have provided the ip and port
If the server is working or not I still get the alert...
I have also checked the manifest of the app and it has the appropriate permissions: android.permission.INTERNET
I also added a js error handler to check if there is a js error:
window.onerror = function (errorMsg, url, lineNumber) {
alert(errorMsg);
}
var MyApp = angular.module('scotch-todo', ['ionic']);
...
I had a small error and fixed it (so the handler works) but now nothing is catched...
If I understand correctly, you can connect when developing on your PC, but now when testing on your physical device.
Since Cordova v4, they changed the default behavior so it won't connect to any address outside its own WebView pages. There exists a cordova whitelist plugin that lets you connect to a list of address in the whitelist
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments