Debugging Google Web Application projects with Google Cloud Endpoints in Eclipse - java

My iOS app uses a Java-based server and communicates with it using Google Cloud Endpoints. Normally the server listens on https://myservice.appspot.com/_ah/api/rpc.
How can I debug my server code? After I run it with Debug As | Web Application inside Eclipse and change its URL to https://localhost:8888/_ah/api/rpc the client cannot connect. I don't think it's a firewall issue because URLs with localhost:8888 work for other client-server pairs.
So does one need to take any special steps for debugging code in Google Web Application projects with Google Cloud Endpoints in Eclipse, and is there a better way to set their required URL on the client than hardcoding it (like I currently try)?

The first cause why this did not work was that I tried to connect to localhost over SSL.
The second cause was that my real device of course needs to contact the dev server not as localhost, but using its remote IP address (currently 10.0.0.2 on my WLAN).
The third cause was that the firewall on my OS X 10.9.3 Mac prevented my real device from connecting to its port 8888. I had to disable Block all incoming connections and allow incoming connections for the applications Eclipse and java under System Preferences | Security & Privacy | Firewall Options. (OS X will prompt for permission the first time a connection is attempted.)

Related

I can't connect to my dropwizard application remotely

I am able to succesfully use my dropwizard application when accessing with localhosts, but it doesnt work when I access with a different machine. Is there something you need to do make your web application respond to hosts besides localhosts?
I know with flask you must run with the flask run --host=0.0.0.0 is there a setting in the config file which controls this.
If you connect from the same network you´ll probably have an windows firewall issue (if you run on windows) or any other firewall depending on the OS.
You´ll have to allow inbound connections for the specific application on or port 80/443 TCP.
If you´re trying to connect from another network then it probably still is the above but you also have to setup port-forwarding to the machine running your application.
If it´s HTTP, probably port 80. If HTTPS then probably 443, for any other protocol you have to find out the correct port.
Since it´s dropwizard it´s probably HTTP/HTTPS, depending if it has to be secure (definatly recommended for REST APIs)

Cannot connect to EC2 web app from external browser

Recently I stopped and started my EC2 instance which resulted in having to setup my web app from scratch (using Tomcat & Java).
Right now I have Tomcat running on the EC2 instance and I can properly access my web app by opening a browser on the EC2 server and pointing to http://localhost:8080/web_app_name
However, if I open a browser on my own PC and point to the public IP of the EC2 instance (e.g. ec2-XXX-XXX-XXX-XXX.ap-southeast-2.compute.amazonaws.com) then the browser returns the message:
"This site can’t be reached, ec2-XXX-XXX-XXX-XXX.ap-southeast-2.compute.amazonaws.com refused to connect."
I have checked my security group for this EC2 instance, and it is allowing TCP ports 80, 443, 3389 and 8080 so I'm not sure why I cannot connect to the web app.
How can I resolve this?
You can try one of the below:
Create a new security group with an inbound rule "Custom TCP" giving permission to ports: 0-65535 and CIDR of 0.0.0.0/0. Attach this security group to your EC2 instance
If you don't want to create new Security Group make sure your current inbound rules has just one rule giving wildcard access like the one above.
As your application is running on 8080 port and ec2 Instance IP is looking for your application on 80 port.
So use loadblancer for redirecting port 80 to 8080 or try
ec2-XXX-XXX-XXX-XXX.ap-southeast-2.compute.amazonaws.com:8080/web_app_name, you will able to render your web page.

Accessing Google Cloud VM Instance Tomcat using External IP

I am trying to access my Tomcat HomePage which is inside my Google Cloud VM Instance with External IP address 35.189.85.127 and Internal IP 10.154.0.2. On my local machine, in my browser I tried http://35.189.85.127 and http://35.189.85.127:8080 but got error
The connection has timed out. The server at 35.189.85.127 is taking too long to respond.
I have seen all the questions and replies on stackoverflow regarding this question but still I found no clear solution.
The steps that I've done so far:
I have setup a Google Cloud VM instance in Compute Engine. I am using Windows Server 2016 as the image.
Using RDP I log on to Windows Server.
I successfully installed Java 1.7 and Tomcat 7 on Windows Server.
I tested Java and Tomcat 7, both are working fine i.e. I open browser and type localhost:8080 and it shows Tomcat HomePage.
I replaced localhost with my VM Instance Internal IP i.e. 10.154.0.2:8080 and it again correctly shows Tomcat HomePage.
Now I try to access Tomcat HomePage using my VM Instance External IP (Static) 35.189.85.127 but in my browser I get error
The connection has timed out. The server at 35.189.85.127 is taking too long to respond.
Faced the same issue today.
Noticed from your question that you're using an Windows environment.
On Windows
Be sure that the Windows Firewall is properly configured to allow traffic under the ports you need (or deactivate it).
On GCP
Under "VPC Network/Firewall Rules", create a new firewall rule and configure as below:
Firewall Rule Parameters (image)
Or, you have the option to check the "Allow HTTP traffic" option under the Instance Configuration menu and edit Tomcat's server.xml to startup at port 80, as described here:
Change Tomcat Port Tutorial # StackOverflow
Option1: If it's just tomcat. GCP offers a click to launch Tomcat instance with an external IP. You can SSH and also have a temp tomcat username and password to manage any of your deployments.
https://console.cloud.google.com/launcher/details/click-to-deploy-images/tomcat
Option 2:
If you wish to have a Google Cloud VM instance in Compute Engine.
You will need to setup security groups and assign it to your instance.
Eg. Define rules to Open Tomcat port 8080(or any) externally / range. Assign that group/rule to your VM instance.
There are many options available, it all depends on how you wish to organize things. You could create a VPC and add your instances there or keep them under the same subnet or have them accessible externally etc.

Could not connect to ActiveMQ service running on AWS - EC2

I am trying to connect to aws-ec2 instance having activemq service running. I am trying to connect it using tcp transport connector using an application built under java + maven + git setting.
I am doing this exercise to add network latency to compare activemq with aws-sqs, which will help us in deciding which one to use for our requirements.
what I have tried so far:
I am able to run this application locally as I scp'ed into ec2 added my code there and it ran locally, which led me to believe that amq service is running.
I also ran the same setting from my home network it is working fine, so home computer -> ec2 connection is also working.
It is just not working from my office network, which led me to believe that it is failing because of some kind of firewall setting?
A simple netstat -a | grep 61616 gave me that it is listening on port 61616.
Does anyone know where I am going wrong? Or suggest some more debugging techniques?
EDIT: Security rule at aws-ec2

Amazon EC2 server TCP Socket Connection

I have developed a Java server using Eclipse that accepts TCP socket connection from android client, performs some computations, and returns the result to the android phone using this socket. I tried it on Wi-Fi.
I want now to move the Java server to the cloud - basically amazon EC2. Is this possible? I am just using a simple tcp socket connection. I have checked and couldn't find an example but came across "elastic beanstalk". Any help is appreciated, maybe a link or tutorial with such an example.
can i convert my java project to .war and use it or can i install eclipse on the cloud and run it as i do locally?
It is definitely possible. And you don't have to convert your project to a .war, unless you want to.
All you have to do is:
Pick the Amazon Image (AMI) you want to use - Amazon Linux is a good place to start, but there are plenty of other options, including Ubuntu and Windows.
Set up a security group - you need to set an incoming rule for your server's port number. It is pretty easy to do this from the Amazon web-based console.
Start a machine and assign it to the security group you created. Again, this is easily accomplished from the amazon web console.
Once the machine is up, log in (using ssh for Linux or Remote Desktop for windows) and install your server.
A few things to remember:
Since you are now running on a public server, sooner or later your server will be attacked. EVERYONE gets attacked. If all you are opening is your single application port, make sure it is secured.
An Amazon server has a private and public IP. Your client application will connect to the public IP.
Servers can fail, and new servers get new public IPs! You need to prepare for this. Either make the IP in the client configurable, or look into something like Amazon Elastic IPs or dynamic DNS.

Categories