Hey everyone,
I´m building a Ionic 2 App for windows 10 that needs to communicate with a server running on localhost.
All works good if I run my application in a browser (either with ionic serve
or ionic run browser
) but the communication between App and LocalServer is not working if I launch the application with ionic run windows
and I´m unable to get any error message (the rest of the App works fine).
In a scenario where the server runs on another device (not using localhost) all works good again… The issue is that I need to have the App and the server running on the same device, any tip on what is hapening and how this can be solved?
Server:
var io = require('socket.io')();
io.on('connection', function(client){
console.log('Connected...');
client.on('message', function(data){
console.log('message: ' + data);
});
client.on('disconnect', function() { console.log('Disconnected...'); });
});
io.listen(3300);
Client methods (Ionic 2 App):
connect() {
console.log('Connect...');
this.socket = io.connect('http://127.0.0.1:3300');
}
disconnect() {
console.log('Disconnect...');
this.socket.disconnect();
}
send() {
console.log('Send...');
this.socket.emit('message', 'test message...');
}