For debugging purposes I set the IP address on my phone to 192.168.178.220 and this connects to my PC over a wireless router to access a web app I have running in IIS on my PC. The web app uses 192.168.178.201. I have to use the desktop app DnsSpeeder to act as my DNS server in order for my phone app to communicate with the web app using its domain name instead of its IP address. I need to do this because I use a subdomain that shares the same IP address with other web apps.
Normally this works but if I leave my phone untouched for a minute or so, the phone cannot resolve the domain name. I even tried a third party tool and just entered the IP address and it cannot connect to the web app. But after a few minutes the connection works fine with either just the IP address or domain name. If I use the third party tool to ping a site that is on the Internet, like google.com, there also appears to be a long delay.
My Internet connection appears to always be on and under my settings I have it set to never go off, so I can't see how it could be the WiFi radio itself.
Could the problem be with using a LAN IP address or is it something else?
Interesting! Sure sounds like something is going to sleep on the phone. Have you run a packet sniffer such as Wireshark on your PC to determine if the expected DNS requests are making it from the phone to DnsSpeeder?
Related
I am using the NanoHttpd library to set up a server. It is currently serving a 'Hello World' HTML page.
It is accessible from the browser of the phone on which it is deployed but not on other phones or laptops on the same WiFi.
For example, http://10.54.92.228:8080 is accessible to the browser of the phone on which the server is deployed. But, is inaccessible to other devices over the network. Is there any way to enable incoming connections ?
I am working on a similar project, I have to host files over WIFI on an android device which is accessible to anyone on the same WIFI network.
The web server is working as I want.
I think the problem is with your IP-Address of the server.
For a WIFI network, the network should be in the range of 192.168.137.XXX.
What you are inputting is the global ip of the device on which your server is.
Check you local ip, and enter it with the port number and it will work.
Ping me if you need any help.
Disclaimer: I don't know this is the actual problem, I just suspect it is.
I have set up an Amazon Web Services EC2 instance as a remote git server. I have had to configure it to only accept incoming traffic from a single IP address though I had wanted to make it open to all because I will be using it while I travel.
The complication here is that mobile phones cannot have a static IP address and I will be accessing the server using my android phone tethered to my laptop. This means I have to make a new rule to accept traffic from my current IP address before connecting to the server via ssh.
When setting this rule there is an option to use "My IP Address". Amazon automagically checks my current IP address and sets it in the rule. It looks like 123.123.123.123/32. The "/32" part there being the actual end of the address.
When testing the server from home I have no problem accessing the server from my desktop computer over the home network with static IP. Equally no problem accessing the server from my laptop computer over the home network. I then tethered my phone to my laptop and tried to access the server via the cellular network with the home static IP address rule still in place. As expected the connection was not made because the phone is allocated a different IP address.
BUT...then I go out for a day of coding in a nice location and try to connect to the server and it does not work. I went in to my EC2 console and set a new rule to accept traffic from my current IP address over my tethered phone using the automagic "My IP Address" setting. Then tried to connect to the server via ssh. No joy.
The connection is not made. Just times out in the same way it did when I originally tested trying to access from an IP address not specified in the rule.
So I was thinking it has something to do with ports. Is that what the "/32" above is? Or have I got that all out of whack?
What can I do to gather more information to help define what the actual problem here is?
I had this same problem connecting to a Postgres database in AWS. Here is what I did to solve it:
I opened up the server to everyone 0.0.0.0/0
I went into the server and determined my actual ip address that it was trying to connet with.
Went back and fixed my rule with that IP address.
My automatically populated IP address was different than the actual one.
Find an Android VPN provider that will sell you a static IP for every use. That might be a way to use a static IP as a security measure. If the VPN provider offers the service on PC as well you can set both to the same IP. Your really ambitious you could set up a VPN service on your virtual machine and then configure it to only except connections from it's self via SSH. You would have to Adjust your "security group" to except VPS connects from any where. The second method would mean that you wouldn't need two static addresses for and added layer of security.
I am struggling with this for three days now. It is an android client application that connects to the server AIR application through Wifi on local network.
I need my application to connect to the server every time it is launched without asking the user to enter local IP, in case it changed.
It seems there are many ways to make sure the connection is successful, but I want to make sure I can go without the help of RTMFP or PHP or SharedObject stuff.
I am able to get local IP using NetworkInterface and NetworkInfo ANE from Android client. Then I use the variable to
mySocket.connect(ipAddress, 8888);
But there is a problem:
1) When debugging on Android via Wifi
The detected IP 192.168.137.2
2) When debugging on Flash, on computer
The detected IP 192.168.137.3
So, the local IPs are not the same. So client fails to connect. Everything works perfect, if I manually set that IP, but I need a code that works, even if the IP on local network changed.
As I mentioned making a textInput field in case IP changed and ask the user manually enter IP is not an option.
My question is why using "localhost" as host parameter of socket.connect(host, port) does not work? If it did, there would be no need for detecting local IP at all. "localhost" works for me only if the client is running on computer, but not Android.
Is it the problem with Security Policy file? if so, I have no idea how to use that. I can't find any tutorial on that.
You have two devices
1. Android device running an app and acting as a client
2. Computer running an AIR app and acting as a server
Each of those devices will have it's own IP address on the network. In your case android device IP is 192.168.137.2, and computer IP is 192.168.137.3.
In order for client to connect to server there must to be some means of delivering server IP to the client. Normally for an app like this you enter server IP address manually in settings, or have one central place available on the net where server registers it's IP address and client fetches the address from there.
Since you don't want to use any of these options the last resort would be implementing local area network scanning. Where you scan all the segment 192.168.137.* and search for opened port reserved for server. That of course is not good implementation but could work if project is for your own use.
Lastly "localhost" is name mapped to loopback IP 127.0.0.1 which is special address and is used to connect to the same device app is running on. In your case if android app is connecting to localhost it is trying to connect to the android device itself.
I am writing an android app for a friend of mine who is a DJ. Instead of guests writing requests on a sheet of paper, he wants them to request songs through his android tablet. I have the app working through the internet but some places may not have internet. One solution was for him to bring a router and just connect the laptop to tablet that way.
My question is: how do I connect the two locally? What would the ip address for the laptop be? Where do I have to look to find it? Is there an easier way to connect the two?
I'm a pretty big networking newbie.
Thanks,
Eric
A really easy way to do this would be make a small webapp to run on the laptop, and just point the android tablet's browser to the laptop's web server. If you want a little more control on the tablet's browsing (so browser controls aren't available so people can't navigate away from the app / bring up "inappropriate" websites / etc.) create a little android app with a webview to load the webapp.
Edit: This assumes you have a router or something to create a network connection between the laptop and tablet. You could set up the router to always give the same IP address to the laptop and tablet. The specific directions for how to do this depend on the router you have - but for most you just go to the router's IP address (usually 192.168.0.1 or 192.168.1.1), login as an admin, and follow directions to set up "static" or "fixed" ip addresses for devices connecting to the network.
Depending on what other forms of communication the laptop and tablet have in common (bluetooth? IR port?) you could write an app on each computer to talk to each other without needing a router - but writing these programs is going to require writing a lot more "lower level" communication between the two apps than using HTTP.
You would have to configure the access point/router to grant a fixed IP address to the Android's MAC address and do the same for the laptop's MAC address.
Write a small web server on the tablet that refreshes the page after each new song request. Have the laptop web browser connect to the tablet's fixed IP address by visiting http://192.168.1.1, but of course replace this number with the IP address you configured. You could also reverse the roles and submit the songs via the tablet's web browser on a web server running on the laptop. And tell your client to keep a close eye on that tablet!
I got this crazy idea that I don't know is possible or not... what I want to do is set up my phone as wifi access point, then allow people to connect to it, but handle all incoming http traffic myself.
So:
phone wifi in access point mode; open wifi network (this tidbit works - yes I know it's not officially supported but then I have no intention to distribute put this app on the open market or so, it works on my phone and that's good enough for me).
client can connect to the phone (e.g. my laptop: this also works).
when client tries to open an http connection to any random server, this has to be intercepted by my app and handled by a local web server. This is the point that I'm stuck on.
The web server part shouldn't be too hard; there are (open-source) web servers available. But getting the traffic to that web server, there is the problem.
The behaviour I'm after is a bit similar to what you get when connecting to some open hotspot, like hotel hotspots, that then redirect you to a login page. This intercepting of the connection request (I suspect I have to look at DNS requests?) is what I'm after.
I have seen an app that is doing this but they require the phone to be rooted. I'm hoping to find a way to do it without rooting the phone.
Wifi hotspots would usually use IPTables to redirect port 80/443 traffic to a local web server.
I have run squid on linux machines in the past on port 3128, then sent all port 80/443 traffic to squid. Then I used squid redirect any url that I didnt explicitly allow to a local web server.
IPTables is accessible on rooted android devices only though.
And I doubt there are many proxy servers available on android, so you would have to send HTTP traffic to a proxy server over the network connection.
Like has been said, you'll need IPTables, but you'll also need a proxy server, like Squid.
Google "transparent proxy with squid", or check here:
Linux: Setup a transparent proxy with Squid in three easy steps
you do not need to have a proxy, you just need a full LAMP stack on your device and IPtables, you can mark all packets that have not been authenticated to forward through to your local page, then using php change the rule for that IP address once the address has authenticated, you could do the same for mac addresses if you wish, you would then also need a daemon that periodically reset each exception