Google compute instance is not accessible with external ip and port - java

I created a google compute instance on https://console.cloud.google.com/compute/instances
After that I deployed a jar file embedded jetty server running on port 8082. I execute the jar file with java -jar command.
In VPC network I add a firewall rule to open port 8082. Now if I try to access the google instance at port 8082 in web browser I am getting connection refused error. Below is the external ip address with port
http://35.184.211.81:8082
I don't know why above external ip is not working. If I open cloud shell and open web preview on port 8082 then I am able to access my web application on port 8082 below is the url
https://8082-dot-3144491-dot-devshell.appspot.com
It looks confusing. Above adress is showing that my application is deployed on google cloud instance but it is not accessible using external ip.

I solved above issue by myself.
The problem was that I was using google cloud shell to deploy my application. I run the java -jar command in google cloud shell. I don't know why changes made or program executed in google cloud shell are temporary so that's the reason my application wasn't accessible on external IP.
I connected my instance using SSH, run the jar file and then my application is accessible on external IP with port. In https://console.cloud.google.com there is an option to connect the instance with SSH so i use that option.

Related

Web application unable to connect to Postgres database on virtual machine

I have created a web application in Java and hosted it on a VM. It is getting hosted as I can see the start page of web application. But the problem arises when the hosted web application tries to connect to the Postgres database.
This web application is properly getting connected on the local host if I use the following connection string for JDBC:
DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres",
"postgres", "password");
But when hosted on VM it is not getting connected. I tried everything from other stackoverflow thread like this to change the configuration files of Postgres in VM but still it is not working.
Note: Postgres is also running on VM.
I have converted my web application from local host to .war file and deployed this file on the VM.
Can anyone tell if I have to do any other additional settings in order for the hosted web application to query the database in the VM?
Resolved this issue. The problem was that I didn't include some of the jar files that I was using in the web application in Apache Tomcat lib folder.
Do you also run Postgres on VM ? If not you can not connect it through localhost since the localhost for your web app is VM's address. If so check the firewall and allow the 5432 port to be able to connect.

unable connect to java app running on server (Heroku)

I deployed my app on Heroku. It is a simple app that will throw back the message sent from its client version (running on my PC) back to the client. My server app prints the IP address of the machine it's running on so I can connect to it from my client . I do get to see the IP address of Heroku machine when I deploy and run it. However, I am not able to connect to it from my client version using that IP address(Connection timed out) . I have allowed the port I am using in my firewalls. I don't understand what I am doing wrong .
Pls help me solve it.
If you need to see my code let me know ( the app works fine locally on different terminals so I don't think it has a problem).
Your Heroku dyno (an isolated server) is behind a router. You can't use the IP address to connect to it.
Instead, you the URL https://[appname].herokuapp.com where "[appname]" is the name of your app.
You can also run heroku open from the command line.

OpenShift upload jar and run it

Hi there I have a simple jar that works like a server, can I upload it to my OpenShift account and run it ? How by the way ? Thanks alot in advance.
You might need to provide a few more details. If you want to upload a .jar file and have it run, you will need to add it to your git repository and then create an action hook that runs the .jar file (java -jar /path/to/file.jar &) and then do a git push. if you want to include the jar file for your .war web application to use, you can check the KB articles section of the openshift website for examples of how to do that.
Only port 8080 on a specific IP is exposed to the outside world. Check the docs for the environment variables such as ${OPENSHIFT_DIY_IP} and ${OPENSHIFT_DIY_PORT}. (Note the public connect via port 80 but they are connecting to the openshift infrastructure which forwards to your app running on port 8080.)
An example of running a jetty server as a jar is given at https://stackoverflow.com/a/33114072/329496 which builds a WAR file then has a start script which runs jetty as a JAR assigning the host and port using those environment variables.
To be honest if you are building a JAR and pushing it to the server you could use just use Amazon Web Services to get a host without any added extras. OpenShift is PaaS (platform as a service) whereas Amazon Web Services is IaaS (infrastructure as service). If all you need is linux and java that is very well supported with any IaaS. They also have less restrictions on a raw linux virtual machine such as being able to run on port 80. As an example I used to build JARs to run on OpenShift but they don't have full support for websockets (you have to use a high port which is not acceptable to many corporate web proxies). So I moved over to AWS and it was very easy to get things running there.

Can't access OpenMary TTS from Azure endpoint

I just deployed an instance of OpenMary TTS server on my Windows 2012 Azure VM and configured ttp endpoints for both port 80 and the default 59125 ports. I've tried launching mary server using both ports and I can't access it externally using either the DNS name or the external IP. I installed IIS on the same host and I am able to access the default page remotely so I know it is not an Azure configuration issue, rather something in OpenMary causing it to only accept requests coming from the loopback IP or localhost.
Is there a hostname setting I can supply on the cmd line via java property? I can change its port name via -Dsocket.port= setting but how do I tweak the host name it listens on? Does it make sense to set the server up behind IIS?
in the Windows Azure Portal, you need to configure the end point mapping.

Running Jetty web server in LAN

GAE comes with an inbuilt jetty webserver for testing purpose.Can it be configured to accessed within our LAN?
I can access it using http://localhost:8888 or http://127.0.0.1:8888 but can't access using http://192.168.1.201:8888 (This my local LAN ip)
why?
Yes it is possible:
To make your GAE accessible on your LAN, you have to configure the launcher to use the address 0.0.0.0 instead of localhost.
Open the GoogleAppEngineLauncher >> Application Settings for your app
Add “-a 0.0.0.0″ to the Extra Flags section and restart. Now your GAE will run in your LAN and can be accessed by other devices.
You need to configure GAE to listen on all interfaces, not only localhost's loopback interface (127.0.0.1).
For IntelliJ IDEA users (version 11 at least):
If you're using the GAE plugin and have a AppEngine Run configuration, open its settings and add to Server parameters: -a 0.0.0.0. This will make the GAE built-in Jetty server to listen on your lan/wlan ip address, http://10.0.1.2 for instance.

Categories