How to access NodeJS from another network - android

I have a NodeJS server that I'm currently working on in my machine. The OS is Windows 10.
I'm part of a small team of two and we are currently in a stage of development where i'm branching out to android app development and the other guy is making additional changes to the NodeJS server.
Thing is, when we gather and use the same network, I can successfully connect to the server being hosted in another computer via the app by using target computer's IP_address:port when making the HTTP request, but when we are "home-office-ing" we can't seem to be able to see or connect to the server being hosted in each other's machines.
Even by using the http://192.168.0.x:port ,address which works when we are connected in the same network, we can't access and get ERR_CONNECTION_TIMED_OUT when in different networks.
The port we are using to open the server is port 80, but we tried with port 3000 and forwarded it on the router, and still, it doesn't work
Is there a way to open up the server so it can be seen by a computer in an outside network?(I know that it will also be available for any other computer to see and interact with the server)

You have to use public IP address.
The most easiest solution is to rent a VPS with public IP address.
Just Google 'rent vps server' to find any hosting provider.

Related

Debugging HTTPS local services from my mobile device (web, api, websocket)

Having a hard time debugging from mobile device my local development web app which connects to a GraphQL node server and another service using web sockets. All three services running on HTTPS to the below ports.
Web Reactjs app: https://localhost:3335
Node server: https://localhost:3334
Web socket server: wss://localhost:4443
From my macOS machine, everything works as expected but when trying to access the reactjs from Chrome Android and using the inspect desktop devtools and USB cable navigating to https://localhost:3335 works but I get the error POST https://localhost:3334/dev/graphql net::ERR_CERT_DATE_INVALID.
My iOS device doesn't even connect to localhost:3335 or 192.168.2.3:3335.
I am open to any tips, tricks, services, and ideas to debug using my local development machine and mobile devices.
I was able to make it work by navigating to all addresses in the mobile browser and accept the risk of a self-signed certificate.
https://localhost:3334/dev/grapqhl -> accept
https://localhost:4443 -> accept
Now https://localhost:3335 will work fine.
Struggling with iPhone debugging due to localhost not binding to the machine IP address (Pending solution, might create another SO question for reference).

How to connect an android app running on a device connected via ADB to hit REST API on local server?

I have a multi-tenant web app like
http://xxxxx.constant-domain.com:8080/
in my host file
127.0.0.1 xxxxx.constant-domain.com
The device that has the android app running is connected via ADB which calls my webapp's Rest Apis to get and send data and
It runs fine on dev and prod environments like
http://xxxxx.dev.constant-domain.com/get-data
but the problem is I want to debug it on my local server. I tried adding the given domain as base url but it doesn't work.
I tried adding http://localhost:8080/ as well but it doesn't work.
I tried looking for questions here but didn't find anything that would help.
I'm using retrofit for Api calls.
Any help would be appreciated.
First of all, make sure that your local server and your device are using a same wifi. And then find out the option to put your local server online. There is an option in Wamp Server to put it online. I don't know which software you are using to setup apache or any kind of server on your computer.
And then you will be able to access your local server by ip address. Also there is an option to edit virtual hosts of your server to allocate a specific port that the app can connect.
It doesn't matter whether you use Retrofit or Volley or Okhttp or any other things. You need to setup your local server to be online within your local network.
I figured it out. All I needed to do was to set my private Ip as
http://192.168.8.400:8080/get-data
Hope this helps anyone who is in this situation.

Debugging an App, that needs a URL to a server

I have a Xamarin Solution with an Android, iOS, and Windows mobile solution. I also have a Web Server that sits on localhost:XXXX.
I need to be able to access the URI endpoints on my local, while debugging on Mobile.
While the Web Server is running I go to fiddler, and compose http://localhost:XXXX/api/Locationsand everything is correct, I get the JSON data and life is good.
However when debugging the App on any phone, I suspect the endpoint on the phone is trying to access it's own "localhost". Is there a hosts file that I can edit on the emulators? or another solution?
If you have WiFi, change localhost to your local IP address and connect phone to that WiFi

Access Java Web application running on a server by Android device thru wifi

I have searched for a solution to this but could not find one. If this is already answered, sorry, please direct me to that.
My problem is this. I have java web application running on a local intranet (Tomcat 7, Java 6, MySQL). All desktops within the intranet are connected thru LAN and access the application using the specific server IP, something like 198.162.2.10.
Now, I want to access this thru my android mobile phone as well. The entire building is Wifi enabled and I'm able to access this web application, if I know the IP and enter it in the mobile browser. But, I would like to make this mobile access automatic and wrap it in an app which on click access this automatically, even when the IP changes. We have dynamic IPs.
You can use WebView component to display a web page within your application.
As alternative you can use HttpURLConnection co perform Http request and posts to your web application.
Regarding the dynamic IP you can configure a Local dns server or assign a static IP to the server.
Anyway the application need a fixed address to connect to the web application, unless you want to insert the address manually each time.

How to test my own ASP.NET Web API in localhost:port using android or Windows Phone device (no simulator)

I'm trying to develop my first REST Service using ASP.NET following this guide.
I'd like to test my services in localhost using my android and wp devices without using android and WP simulator (too slow).
Is there a way to do that?
If you deploy the ASP.NET app on IIS, the services will be reachable as long as the phones are connected on the same network (via Wifi for example). Just use the IP adress of the server instead of localhost.
Another idea is to use fiddler's proxy option. (This also assumes you have set up your app in IIS). Check out this article.
This approach is especially useful if you want to test using custom host headers over SSL.
With this approach you can simulate production dns (by altering hosts file on the fiddler host) rather than using IP addresses and machine names from the mobile device.

Categories

Resources