levshkatov levshkatov - 3 months ago 22
Android Question

Debug a server for android on nodejs

I'm trying to create a

node js
server for android phones. How can I create it at home in a local network without outer internet connections? I have wifi at home so my phone can connect to local network. I use official
socket.io
tutorial and I don't know what to write here (instead of
http://chat.socket.io
):

private Socket mSocket;
{
try {
mSocket = IO.socket("http://chat.socket.io");
} catch (URISyntaxException e) {}
}

Answer

open command prompt on your PC and hit ipconfig. note down your wireless IP address. Let's assume it to be 192.168.1.10. you can also set a static IP for your PC on your router. Next from your socket io code check what port number you are using. for example

http.listen(3000, function(){
  console.log('listening on *:3000');

says that you are using port 3000.

Hence in your Android code you need to use http://192.168.1.10:3000/