node.js - (IONIC 2) Error : socket.io integrate express, GET http://localhost:3000/socket.io/?EIO=3&transport=polling&t=LvraMVg 404 (Not Found) (WEBRTC) -


i got error, i'm trying access node server ionic2,

information :

1.i building node server on own laptop 2.when i'm running ionic serve, working normal.. chat no problem, good.

problem : 1. when i'm running on android device, using command ionic cordova run android, error, when check inspect -> console,

and console says :

get http://myipishere:3000/socket.io/?eio=3&transport=polling&t=lvramvg 404 (not found)

i attach code below. server.js

var socket = require('socket.io'), http = require('http'), server = http.createserver(), socket = socket.listen(server);  socket.on('connection', function(connection) {     console.log('user connected');      connection.on('sendid', function(id){         socket.emit('id', id);         console.log('triger isi apa : ', id);     });      connection.on('message2', function(msg){         console.log('triger isi msg apa :', msg);         socket.emit('message2', msg);     });      connection.on('message', function(msg){         console.log('triger isi msg apa :', msg);         socket.emit('message', msg);     }); });  server.listen(3000, function(){     console.log('server started'); }); 

this ionic2, try access server

this.statisticserver="http://myipishere:3000/"; console.log('server :', this.statisticserver ); this.socket = io(this.statisticserver); 

already solve,

i added whitelist plugin,

cordova plugin add cordova-plugin-whitelist --save

hope case other on future..


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -