Testing local online application on actual mobile device with dynamic IP address - android

Im currently developing a number of online applications with mobile friendly interfaces and would like to test them on my mobile device without having to upload (having problems with my internet connection)
Ive researched and seen there's a way it can be done with static IPs but since my internet connection requires an automatically assigned IP. Can this procedure also be done with a dynamic IP
My nachine and device specs are
Windows 10 64bit
Android 4.4.2
Xampp/Apache
Thanks in advance

There are two ways of achieving this
1) Server behind router
In this approach, you simply use your home/work Wi-Fi to connect to the server, hooked in to the same network. Later on, buy a domain/sub-domain and publish there.
2) Server beyond router
This will require some hacking in most cases. There are websites out there that provide dynamic DNS options. Almost all after-market router firmwares will support registering on to (many of) such websites. And then do port-forwarding to the server behind the router. In essence, you're asking for someone on the outside, to redirect traffic to (your) server, which is on the inside(behind the router).

Related

Connect to Android TCP Server App from Internet (w/o Router): Impossible?

I'm trying to write an Android app to accept TCP connections from the Internet. Sounds simple but despite weeks of head-banging, I've found no solution and now believe it impossible. I would love to have someone tell me I'm wrong.
I was encouraged by the "ServerSocket()" API function. I was able to create a listening socket (e.g. on port 2000) and connect to it from another app within my device. Unfortunately I find it is bound to (unrouteable) local address 10.0.0.150 which, of course, cannot be seen from the Internet.
I was also able to successfully connect by pointing my device to my local WIFI router and using the router's "Port Forwarding" feature to relay incoming connections to MyPublicIp:2000 to 10.0.0.150:2000. But this is not usable in the field (over an LTE connection) where I have no router.
I've searched StackOverflow and other sites but found no good answer (but plenty of inapplicable or obtuse ones).
From my reading, I hear that most (all?) carriers do not allow incoming connections to be routed to user devices, which may explain my dilemma.
PLEASE: Someone tell me I'm wrong.
I think it is possible.
Looking information about my mobile operator (mobile provider): it can provide a static IP address and my mobile device is available for incoming sessions, but only need to pay for this service.

NAT punch-through on mobile network for p2p model?

I am writing a p2p messaging Android app, and I'm trying to solve the problem of NAT on mobile networks. I cannot currently find a way for a device to connect to another listening device on a 3G/4G network due to the carrier's NAT service.
I have heard of a few NAT punch-through methods, but a lot of those involve using some sort of centralized server as a mediator. I am trying to use a completely decentralized p2p approach to accomplish this task.
Are there any feasible ways of allowing a device on a mobile network to be publicly addressable?
Thanks!
No, it is not possible. Most of the time, subscribers with IP addresses NATed are behind NAT444 and many subscribers are anycasted ( subscribers have the same IP on their mobile phone, but nated behind a different NAT devices). And 2 anycasted suscribers cannot communicate together.
The only way left you is to open a VPN to get a real IP of Internet Public.
My suggestion would be: Do not use VPN for IPv4 ! Use VPN to get a real IPV6 to your mobile phone application, and build your p2p application over IPv6.
You are fighting with very old problem that drove IETF to build IPv6.
So, go to IPv6, and forget ipv4.
The ONLY good solution for your problem is to build your app over IPv6, and your app has to bring the ipv6 tunnel to the phone.

How to acess my router on home, using 3G data of Android?

I worked on a simple app....which works by sending simple instructions to Arduino over my WiFi router, just like - 192.168.0.177/status or 192.168.0.177/currenttemp etc,while my phone is directly connected to the router.
What I am trying to achieve now,is to be able to send same instructions to Arduino(which is connected to router) over the 3G/2G data of my android(which is not directly connected to router).
I tried to research a bit,but its all is just fuzzing up things more & more....
(I m big nooooob).
So,what should I do to get that to happen?
is it--[PUBLIC IP of router]/status. I just cant understand.
Some port forwarding,router remote access,I do not know. Direction reqd.
++I dont know...how can i get this Public IP,,it quite keeps on changing & if so,,,how to set up.?.? :-(
So this seems like a question of 2 parts - but overall you're going to have to become familiar with your routers status page. It should allow you to do port forwarding (which you will have to do) and may help with your IP changing.
Finding your Router Status Page
Your router status page is usually available from one of these two urls:
http://192.168.0.1
http://192.168.1.1
Hopefully one of these will take you to a web page, where you can configure things- if neither do then you're going to have to find out what the right address is - this should be the same as your default gateway so you can follow these instructions: https://wiki.amahi.org/index.php/Find_Your_Gateway_IP
Port Forwarding
Simply put, for home internet connections you're probably going to use Port Forwarding whenever a device that's not on your network (in this case your phone) initiates a connection to a device that is on your network (your arduino).
This is because when your phone connects it will do so to an internet IP address rather than a local IP address and the internet IP can't specify which device within a local network you want to talk to. If your Arduino were to make the connection you wouldn't need to port forward on your home network.
Within your Router Status page you should find configuration options for port forwarding, without knowing your router I can't say much about where you'll find them but they're usually obvious - once there typically you can pick a port or range of ports you want to forward and which IP address you want to forward them too. Judging by your question the port you want is 80, the default one for web browsing - the IP address you want is the internal IP of the Arduino which seems to be 192.168.0.177.
Once you save that you should be able to make connections to your Arduino from off your network but you've still got your IP issue left.
Dynamic IPs
You're quite right you'll need your public IP to connect, this can easily be found from within your network by going to a site like https://www.whatismyip.com
However as you've mentioned, your IP changes quite a lot, so if you don't want to keep looking it up you've only got a couple of choices:
Pay for a static IP from your internet service provider (if they offer this)
Use a dynamic DNS updating service
Probably the most well known amongst those services is DynDNS though there are free alternatives, it's worth remembering that you may be getting what you pay for and I'd perhaps look for recommendations from other StackOverflow users on which to use.
In terms of the actual updating you have two options, the easier one is to install a client on a supported computer which will periodically update your IP. Alternatively, some more sophisticated routers have Dynamic DNS updating built in and this would also be accessible by your router status page, which you're hopefully already a pro at rooting around in.
yes you need public ip of your router as your both device is not in the same network.

Accessing WiFi LAN (no gateway) and mobile network simultaneously

I'm aware it's been asked before (with limited or no solution) but I haven't seen any recent updates and I think my scenario is unique so I'll start a new thread.
I have a Raspberry Pi and it's functioning as a hot spot among other things. By design, DHCP isn't handing out a default gateway. My use case is one or more devices interacting with the Pi as a server.
One of the connected devices will be a mobile device(edit: running a custom app of my design which is part of the total solution), and that device will maintain its cellular connection, not for tethering or routing but so that the application can access internal and external resources simultaneously.
Currently:
IOS: This works exactly as I expect on IOS - it senses that the WiFi network doesn't have a default gateway and sends external traffic over cell.
Android: This doesn't work at all. Android stubbornly sees WiFi connected and disables cellular, even with no default gateway.
Windows Phone: Kind of a hybrid. Both networks stay up but my scenario has a DNS entry in public DNS, and a public site links to a resource on the Pi. If I link to the resource directly using the WiFi IP address of the Pi, it works fine (although this causes other issues related to security). If I link via a FQDN, I'm actually not sure what's going on. It doesn't resolve from the web browser although every networking utility I've installed on the phone for troubleshooting correctly resolves the FQDN to the Pi address via DNS.
Hope this makes sense. The question: How can I enable this functionality across the board in 2015? :) For my purposes, the Pi as a private nonroutable hotspot works better than WiFi direct or Bluetooth. And remember I'm not asking the phone to ROUTE; I need my custom application to be able to simultaneously connect to the Pi and to the public Internet. I want all the phones to do what IOS does in this regard.
My current scenario is the Pi hosting a web page (among other things) and that's my preference, but can this even be solved natively?
You say that this is not a tethering or routing situation, but if you think about it, it really is both.
It is routing because the traffic from the phone needs to be routed to one of the two interfaces. There may not be routing through the phone, but it's still a routing problem. Fortunately, it seems that the routing part is working on all three platforms.
It is also an unusual form of tethering. The only differences are that traffic does not originate from the Pi, but from the phone, and that the Pi rather than the phone acts as the access point.
Thinking of it in terms of tethering is important because it shows that the Android CAN have WiFi and cellular active at the same time (at least in hotspot mode, but probably also in client mode). In this respect, my answer isn't complete - I can't tell you HOW to accomplish that.
As for the Windows phone problem you mentioned: in order to troubleshoot that, first identify where the DNS server is located that knows about the Pi's FQDN. Does a public DNS server know about it, even though it is obviously on a private network?
There are two possible explanations for your observation:
There is no public DNS server that even knows this FQDN. In that case, IOS is probably using something like mDNS to locate the Raspberry Pi.
There is a public DNS server that knows this FQDN. In that case, maybe Windows Phone checks the DNS reply for martians and rejects it, thinking that it is an attack.
Either way, what you'd really need is to have two separate DNS infrastructures. One way to do this is to include a small DNS server (dnsmasq maybe) with your app, and configure a forwarder for the zone with the Pi's FQDN to forward to the Pi's IP address (which would have to be hardcoded, obviously). All other requests should go to the normal DNS servers.
Another way might be to not use DNS at all, but use the hosts file instead.
For Android phone you can use application named "WiFi & Mobile Data Switch" (https://play.google.com/store/apps/details?id=com.totemsoft.wifimd). For me it solves the problem of simultaneous connecting to internet (via mobile data) and to local network (via WiFi, internet is inaccessible via WiFi). This applications works ok on Samsung Galaxy A8. I hope, my comment helps to somebody.

How do I connect from android device to computer via WLAN?

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!

Categories

Resources