triniwiz / nativescript-socketio

Socket.IO for nativescript
Apache License 2.0
71 stars 31 forks source link

Nativescript-socket io is not connecting to node server #31

Closed narender56 closed 6 years ago

narender56 commented 7 years ago

Hi all,

I have clone the project and ran it but it did not connected with the server. I have used node server but it failed to connect.Please have look at the code.

Node js :

var server = http.createServer(function(req,res){ res.end('hello node'); }).listen(8008, function(){ console.log('HTTP Express server listening on port 8008'); })

var sockerIO = require('socket.io')(server);

sockerIO.on('connection',function(socket){ console.log("socket "+socket); })

Nativescript :

let socketIO; const server = 'http://localhost:8008';

socketIO = new SocketIO(server, {}) socketIO.connect();

When we call connect() function , actually it should fire connection event , which will be listening on server. But it's not opening connection with server.Help me out please

radeva commented 7 years ago

From android emulator you need to use 10.0.2.2 to access the server on your local machine. So just change the server address in your client.

You can read more in this thread