Accessing node.js server on my local system using android app - android

I have a node.js server running on my local system which interacts with postgresql in the same system to fetch and save data. I want to access node.js server from my android app to save and fetch data from postresql. The problem is my app is not able to connect to localhost. As localhost for my phone is different from my local system and if I am providing my system's IP address then also its refusing the connection.

I made server listen to hostname '0.0.0.0'. Initially I was not providing any hostname as argument in server.listen i.e it was like
server.listen('portnumber') which I changed to
server.listen('portnumber', '0.0.0.0');

if you are using android emulator and trying to access the the host machine's
local host use IP address : 10.0.2.2
for genymotion use IP address: 10.0.2.3
this should allow you to access the host machine's local host, but you will have to change this IP address to local IP address when running app on a device and connected to same network, to access from other network you need to open port(port forwarding I guess) in your router and talk ask your ISP to do the same.
here's a link to similar question : here

Related

how to get android emulator to connect to a specific port on our server

I am using Xamarin Forms to build an Android app. The data that the app will consume is stored on our server in a SQL database on our local network. I am using a C# Web API service (served by IIS) to connect the app to the server. All traffic will be inside our local network.
Currently the Web API is being served by IP address on port 90 - this was the only way I could get the emulator to be able to connect to the server, as no luck accessing it by name. I can fire up a browser on my development machine and load up http://10.1.1.15:90/api/Controller and I get back the data I was expecting.
I have also done a networkaccess check for access to 10.1.1.15 on port 90 using Powershell from my machine, which comes back Fine.
I use James Montemagno's Connectivity package to check for network access in the app - this returns true if I check for the IP address. It returns true if I check for the IP address on port 80. However it returns false if I check for the IP address on port 90. How can I get this to access the server on port 90? (BTW it will also need to access other services on port 91 and 92).
The android device was set up by default with a proxy. I toild it not to use the proxy and then it worked

Getting "You don't have permission to access that port" error in Django

I want to run my Django API to my IP address which is 192.168.1.5:81 with port number but I am getting that You don't have permission to access that port.
I have done port forwarding in my router.
I am doing this because I want to get data in my Android application using retrofit.
i checked my available ports on my IP address then i ran code with the open port and solved this.
also i added my IP address inside ALLOWED_HOSTs in settings.py file

how to convert private-ip address to public?

(192.168.0.103) this is my private ip address. I want to convert my private address to public. I am running apache-tomcat in my machine to provide service for my android application. Please help me out what i need to do?
I take it that you mean, 'how do I access an internal machine on my subnet externally'.
Determine the public IP address of the apache server by visiting a site that will show the public IP address (such as www.whatismyip.com).
In any firewalls between external and your apache server, set up port forwarding to the apache server. This will require you to map the inbound connections to your internal server.
On the local firewall on the apache server, make sure that inbound connections to the apache server are enabled.
Connect from your android device to your apache server using the public IP address from 1 and the port set up during port forwarding in 2.
Note: -
Be very careful about exposing internal devices to the public internet and allowing access into your subnet. Make sure that you server is secured correctly. Consider putting the server in a DMZ.
Unless you have a static IP address, the public address is likely to change.

How do you access a local port 8080 url from an android http get

I have a restful web service located on a local tomcat instance.
I'm trying to access the url via a get in my application but am getting the error: host is unresolved
I try to access this url from my android emulator browser to confirm the connection there and am unable to get to it their either. An alert comes up on the screen that says: "an sd card is required to download 125562.bin"
I am not using localhost in my url but something that looks like:
http://192.168.1.2:8080/service/0/12345
It returns straight json
Does anyone know why I can't access this in the android emulator? I can successfully hit this same address from my computer browser as well as iPhone and it brings back json.
Does android handle other ports differently than standard port 80? Is the problem this url doesn't have an extension?
The Android-Emulator has a virtual router, which cut's the Emulators network from the host-computers network.
However, this router is part of the network, too and enables you to access servers running on the local machine by using the IP 10.0.2.2.
So you would use:
http://10.0.2.2:8080/service/0/12345
You need to use 10.0.2.2 to emulate your local machine's 'localhost'.
See Emulator Networking

Access to asp.net web service

I wrote a little WS on asp.net, I can open it printing something like
http://46.146.170.225/RouteGen/Service.asmx
in address bar. It's all right, WS works.
But if I print the same address in a browser on the other computer, the page isn't available. How to get access to my web server from other PC? (I need from Android device, but I think it's no difference)
If you started the Web-Service from within Visual Studio then without changing the starup-settings of your project - it's not possible, because VS only starts a local debug web-server that doesn't allow calls from other hosts than localhost.
To allow external IPs to access your web-server, you have to set up the IIS and run your web-service inside it. A firewall could block incoming requests to the IIS but I ran such a service last winter and didn't have to change firewall-settings.
Verify that the website, in IIS, is bound to a public-facing IP address. Right click on your website in IIS, and go to the bindings setting. Then, check the host field. It should have an IP address or domain name that is available publicly.
Verify that your firewall has Port 80 open for incoming traffic

Categories

Resources