I have just created a Hello World RESTful Java API with IntelliJ IDEA and Spring and I make several requests with http://localhost:8080/function and it works fine and return the JSON data well, but now I want to make request from my android app to get the same JSON data from another network. How to create global API or make my local API global or online?
If it is working on your PC, your next step is to host it somewhere which is reachable from the outside world. If it is still in testing mode, probably what you need to do is port-forwarding from your router, so that your requests to your public IP get forwarded to your PC.
In the long term of course you need to host it somewhere, unless you want to leave your PC running. You can buy a cheap hosting to start with on something like Digital Ocean, or go for the more advanced cloud service providers like Google and AWS.
in your router you have to redirect port 8080 to you network IP and allow port 8080 in your firewall
And use this IP address https://whatismyip.com.br/
You can create your java application in a container and deploy it on one of the cloud providers (AWS, Azure, Google App Engine).
Related
I have an OpenStack installation in my laptop running in VirtualBox windows. I want to access it from my android client and send some computational queries and retrieve the response. I know all about hotspot and networking, Just tell me about the OpenStack setup part and how the client will connect to it i.e. GET/POST requests or sockets, etc.
#Senol has given you links to documentation for the OpenStack "control plane" APIs. You would use these if you wanted to programatically do things like spin up new VMs, configure security groups, create and attach volumes and so on.
But if you want to do a computational task (say) on an existing OpenStack instance that you created on your DevStack installation ... that's software you need to put together yourself. Basically, you setup something on your instance that can accept requests over its private network. That could be via HTTP / HTTPS requests, or via SSH connections, or ... basically anything that can accept TCP connections, UDP packets and so on.
In short:
Set up OpenStack instance, networking, etc.
Install network capable software stack on instance.
Implement your application "service" to do your compute.
In your case, you appear to want your OpenStack instance to be accessible from the outside. Therefore it either needs a public IP (that your Android client can route to) or you need to do some port forwarding from your laptop's IP / ports to the OpenStack instance's ports on its private network. (This is getting "too broad" ...)
Looks like you've been looking for OpenStack api information. You can reach its APIs by cURL, Openstack Cli, REST clients or OpenStack SDK.
The OpenStack API Documentation can be a good starting point.
I have a Java web app on Google App Engine which makes requests to an external API. The API recently requires the whitelisting of IP addresses in order to access its services. Because GAE does not offer static IPs, I understand that one solution is to set up GCE instance (with a static IP) and use it as a proxy for external requests made by the GAE app.
I have set up a f1-micro instance with Debian GNU/Linux 9, and have created a static external IP address as per the documentation.
How do I install nginx and set up GAE to route requests to the GCE proxy?
We faced a similar issue with a client who needed our IP address to be whitelisted. We solved the issue by:
Spinning up a Compute Engine with a static IP address. This is the IP address we gave to our client
Installed Squid on the compute engine (https://help.ubuntu.com/lts/serverguide/squid.html)
We then redirected all calls from the App Engine through the proxy server. You didn't list what language you are using but for PHP, that meant adding the following two lines to our CURL operations:
curl_setopt($ch, CURLOPT_PROXY, "http://" . $_SERVER['SQUID_PROXY_HOST'] . ":" . $_SERVER['SQUID_PROXY_PORT'] );
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $_SERVER['SQUID_PROXY_USER'] . ":" . $_SERVER['SQUID_PROXY_PWD']);
One thing to note is that depending on the number of calls you are making, a micro instance might not work for you. We initially setup our proxy server on a micro box but were having to restart it every few days. We ended up switching to a standard box and have not run into any problems since.
You can solve the issue by configuring your app engine instances and custom NAT instance in same VPC custom network with routing rules.
Related google documents are below;
Configure a Compute Engine VM instance as Nat Gateway (https://cloud.google.com/vpc/docs/special-configurations#natgateway)
Create routing rule for this instance (https://cloud.google.com/vpc/docs/using-routes#addingroute) and (https://cloud.google.com/vpc/docs/using-routes#canipforward)
Configure your app.yaml network properties (https://cloud.google.com/appengine/docs/flexible/java/configuring-your-app-with-app-yaml#network_settings)
If you have complex system, I highly recommend you to create subnetwork and a certain tag to flog which GAE instances to be forwarded to NAT gateway.
I basically need to create a test server, something that I can use locally to perform tasks for my application.
So my android app is basically a search engine, however the search queries will be made on the server and the results then fetched from the server on the mobile device as JSON objects.
Is there any way to replicate this functionality locally? I would just like to set up a server, include the Spring framework, the Google Custom Search API and develop it all in Java, then ship it to a live server directly when it's finished. (Most presumably a free tier Amazon AWS server, either EC2 or Lambda, not sure what the difference is).
Not quite sure where or how to get started so any help is appreciated, thank you!
p.s. I may try dabbling in some machine learning at a later date, but I don't know if this will affect anything, this will most likely be after I've got a live server up and running.
EDIT: Sorry, so how would I fetch data from a local server from my mobile device? Do I need special software? Do I need to configure a local server? How can my mobile device fetch data from a second project when its being run on the first?
My app will fetch data from a server, so how can I create a dummy server, for it to fetch data from? Will I need to create a fully functioning online server, or can this just be done through creating a local server of some sort and then simply plugging my android device in and running the code? I have absolutely no idea how to test it without putting it online.
You can run a local installation of Tomcat server on your own machine.
Access the server by visiting "http://localhost:8080/" (or) http://127.0.0.1:8080". You can basically listening to your own local machine / host's 8080 port. Sometimes, it could be port 80 instead of 8080.
Please explore on how to host a Spring or Java application on a local server.
A good starting point would be to learn J2EE or Enterprise Java. You can configure Databases from your local installation.
If you opt for PHP as your language on server side, there is a pre-defined package called WAMP (for Windows), LAMP (for Linux), MAMP (for MAC) and XAMPP.
The above package are nothing but a package which contains a Server, Database and a Server side language usually PHP, if needed Python or Perl.
Please explain in which step you are getting issues so that anyone can help you exactly.
I want to connect my android application to an applet which is running on my pc on Google chrome on Wi-fi.. where my phone works as a wi-fi hotspot and pc as the connected device. I want the connection to work uniquely as I want commands to be passed from my application to the specific applet, on the execution of which my applet does specific tasks. Please tell me the APIs which I can look in both Java and Android or the technology I have to use to make it work..
You need to use any program, such as wamp server, to make your computer to be a localserver. It will install PHP 5, MySQL and Apache. In other hand, you will also need a little bit of knowledge in Php language to create you own web services.
Another thing you need to be aware is that to handle you connection between server and device (and by this I mean which IP you are going to use) you will have a little headache; but first things first..break your problem in little parts thus will be easier to solve them.
I recommend this tutorial.
I think the simple way to connect these two softwares is using UDP.
It is fast, it is easy to program but it is generally unreliable according to TCP. But it is already local network. I dont think that is a case you need to take care in your local wifi network.
So take a look at this tutorial http://tutorials.jenkov.com/java-networking/udp-datagram-sockets.html
There are other ways like https://www.alljoyn.org/. It has more functinality but more complicated.
You must install Server on your PC(Apache httpd or apache tomcat or other based on your interest). A server listens to request from clients. When your mobile is connected to your pc(doesn't matter wire or wireless), you can make a request to an url(say, localhost:8080/welcome) from your app.
Create an applet and connect it with your web application(in the server) using java.net.URL and java.net.URLConnection.
On performing some operation on the client, call the url of the server application and forward the response to the applet.
I need help with a question that I could not answer yet.
I have the following scenario:
One application Java EE / Flex 4 running on a tomcat, inside my Flex layer I have a iFrame passing a url to an ip of my internal network (http://192.168.1.195:8080/webvisu.htm) which is another application running within an industrial PLC.
When access this app from within my internal network works fine, but when I try to access this iFrame to an external network in my home for example have a timeout error on http://192.168.1.195:8080/webvisu.htm.
I believe this error occurs because the flex client is trying to run this url as I was in a internal network.
Is there any way to run this url from an external network?
Possible solutions:
Some setting on my Tomcat?
A crossdomain.xml file?
I've googled a lot about this problem, but found no solution = (
Sorry for my english I'm using the google translator
192.168.1.* is not a public IP address. The only way you'll be able to access it is if you have your home network connected to the other network over VPN; or if you have a web server set up on your local network which is running on the same IP address.
The use of domain names are supposed to address the problem of accessing IPs directly; but if you're accessing a non-publcly accessible app, you're kind of stuck.
On my current project, for example, the dev server uses an IP Address and the QA server uses a IP address. Neither of these apps are accessible outside the network. I have to connect via VPN to access them.
The production server; however; uses a domain name.