Accessing localhost from android over wifi - android

I have written a Https webservice, so it is encrypted with SSL.
For testing i would like to acces that webservice over wifi.
edit Example: My webservice is running on a VM number 111, i want to acces it over wifi so the adress would be https://VM111/Webservice/service.svc. I can acces it from any laptop in the wifi network but not from the Android Phone, that is my problem.
Is there a way to acces the localhost of the VM, from the Android phone, and has anyone dealt with this before?
My gues is that is has something to do with domains because every other device is in the Active directory.
If there are any questions about my question i am glad to answer them,

You can get a public URL for your server running on a specific port on localhost.
At my work place I could access the local server by using the local IP address of my machine in the app, as most of the other answers suggest. But at home I wasn't able to do that for some reason. After trying many answers and spending many hours, I came across https://ngrok.com. It is pretty straight forward. Just download it from within the folder do:
ngrok portnumber
( from command prompt in windows)
./ngrok portnumber
(from terminal in linux)
This will give you a public URL for your local server running on that port number on localhost. You can include in your app and debug it using that URL.
You can securely expose a local web server to the internet and capture all traffic for detailed inspection. You can share the URL with your colleague developer also who might be working remotely and can debug the App/Server interaction.
Hope this saves someone's time someday.

I found a quick solution to this problem.
try this link, it should help you guys fix the problem.
http://www.mobitechie.com/android-2/how-to-access-localhost-on-android-over-wifi/
I only changed 1 thing, where the tutorial states you change '127.0.0.1' to 'All',
change it to the ip address your server is running on instead.
after that you should be able to connect to your localhost.

I was also looking for something similar
from desktop type ipconfig you will get desktopIP now put that in android browser you should get your localhost

Related

Android Kotlin SSH Connection

I need to connect my android app written in Kotlin with Rpi, and be able to open an ssh connection to it, give some commands, open some files, download/upload files and acces the camera on the Rpi through the App. I already set up the Rpi side, so I have all the required information to initiate an ssh connection (IP Address, username, password, port). Could anyone help me out where to start and/or how to do it, or point me to the right direction ( library, dependency, etc..) ? I only found SSH libraries for JAVA ( like JSch, Chilkat ) and I wouldn't want to mix up the languages.
I tried to search for an SSH solution for android Kotlin, so I could start somewhere, but haven't found it so far.
Any help yould be appreciated
Thanks in advance

my url for json does not work

every time i try to print json file from my wamp server it doesn't work
i use this URL "http://127.0.0.1/webapp/users.php" to acsess the json data
but when i put another link like "http://api.androidhive.info/contacts/"
it works perfectly , so i don't know what is the problem exactly
i'm just starting to learn about json parsing in android .
any help?
my php code is
$row['id'],
'username'=>$row['username'],
'password'=>$row['password'],
));
}
print json_encode(array('result'=>$result));
mysqli_close($conn);
?>
Of course i wont work, this address is local address for your own work station(computer or any device with a ip address eg, your own phone as that address) that is why it is local ip address. Only your system can read and write to it. To over come this dilemma , either one host your on a server, or go the cheap way and broadcast your ip address to the internet using a tunneling software such as ngrok.
Here are some advantages:
Don’t constantly redeploy your in-progress work to get feedback from clients. ngrok creates a secure public URL (https://yourapp.ngrok.io) to a local webserver on your machine. Iterate quickly with immediate feedback without interrupting flow.
Test mobile apps against a development backend running on your machine. Point ngrok at your local dev server and then configure your app to use the ngrok URL. It won't change, even when you change networks.
Building webhook integrations can be a pain: it requires a public address and a lot of set up to trigger hooks. Save yourself time and frustration with ngrok. Inspect the HTTP traffic flowing over your tunnel. Then, replay webhook requests with one click to iterate quickly while staying in context.
Host personal cloud services on your own private network. Run webmail, file syncing, and more securely on your hardware with full end-to-end encryption.
ngrok is easy to install. Download a single binary with zero run-time dependencies for any major platform. Unzip it and then run it from the command line.
After reading and deliberation on some links i received at the courtesy # cricket_007, there is another way to access your local ip address across the network from wamp server.
try this, it works its just a bit longer to setup vs ngrok thats very easy, try the option thats work for you.
Happy Coding :)

I need help finding the url or ip-address to my Openshift MongoDB

I have been searching around for a way to connect my Openshift application to my android application. The Mongo library requires a url but I can't seem to get it to work. Can someone help point me in the right direction to find my Openshift MongoDB url.
This is the only url I could find but it doesn't appear to work:
appname-company.rhcloud.com
Thanks for your time!
MongoDB connection parameters are available as environment variables on OpenShift servers. For example
OPENSHIFT_MONGODB_DB_URL
But your database isn't publicly accessible by default. You'll need at least port forwarding.
did u try this command
rhc port-forward -a <your-app-name>
You will get the ip for your mongodb

MongoDB error: can't call something /127.0.0.1:27017/admin

I am trying to connect to mongodb through an android application, Mongodb is running in local
MongoClient mongoClient = new MongoClient();
DB db = mongoClient.getDB("dbname");
I am getting the error as can't call something: /127.0.0.1:27017/admin
mongodb is running at the back.
I wanted to know why admin?? There is no collection like admin in my DB.
When I connect using the command line, it works, and I am able to insert and query data.
I don't know what is going wrong. Nothing has been mentioned in the examples I have browsed so far about any kind of configuration that needs to be done.
Kindly help!!
Since you are running your application in Android, I would implicitly assume your MongoDB server must be running somewhere else on a different ip address that is not 127.0.0.1. By default, in absence of hostname / ip address, MongoClient tries to connect to localhost loopback address of 127.0.0.1 on port 27017 (default port until something else is specified), and fails because there is MongoDB server instance running on the localhost. I would suggest following:
Look into details of where your server is located and get hostname / port details for it.
Look into MongoDB Java API further and some sample apps http://docs.mongodb.org/ecosystem/drivers/java/ on how to access MongoDB that is running on a different server.
As commented on your question as your client is on a different platform to the server you need to specify the full host connection rather than use the default.
That said:
DO NOT DO THAT!
You most certainly do not want your MongoDB instance accessible over the internet in this way. What you want is a web service to proxy your requests and pass them on to MongoDB. You can do that yourself or look into something that might be listed here:
http://docs.mongodb.org/ecosystem/tools/http-interfaces/
Exposing your database to the internet is never a good idea for various reasons but the two most prominent being security and firewall rules that are not going to allow traffic over certain ports. HTTP is going to be available just about everywhere and is the most useful means of communication for a mobile app.

Local Proxy Server Running On Android Device

I am trying to write a http proxy server that would run on the device itself. In fact, need to find a way to capture the outbound http traffic generated by the device.
The code I have so far is compiling OK, it is based on the code found here: http://www.jtmelton.com/2007/11/27/a-simple-multi-threaded-java-http-proxy-server/
The problem is that the http request to the actual server would block and never return .
Is there a better way to write such a service without rooting the device?
You should check SandroProxy.
Can caputre traffic on non rooted device if os proxy settings are used, or with iptables rules on rooted one.
Traffic is stored it in local sqlite database. Captured data can be also examined by chrome devtools. To capture traffic in your app you should check source code for plugins. It has all the code for iptables redirections and proper settings.
Check out the wiki link on google source code HowToInterceptTrafficOnMyOwn
http://code.google.com/p/sandrop/wiki/HowToInterceptTrafficOnMyOwn
btw: send by sandroproxy support :)
I've been using a piece of software called proxydroid to use my device as a proxy server, and its the only one I've found which doesn't require root. I'm not sure if it will be any help to you, but its an open source project and the code can be found here:
https://github.com/madeye/proxydroid
I have noticed that the application will freeze after a while, or if a large number of request are sent at once, but I've not had chance to find out why this is happening.
Forget about setting proxy, use Facebook Stetho library (http://facebook.github.io/stetho/) to review all http requests and responses from emulator/device

Categories

Resources