Amazon ec2 with windows 2008 server with TOMCAT - java

I just created a free ec2 account. I want to test few things but i want to make sure that i am using ONLY the free version.
I want to run a java application in windows 2008 R2 server with TOMCAT as web server. Ec2 by default doesn't have java SDK and TOMCAT installed.
SO here are the few queries
Will i be charged for installing TOMCAT and JAVA also for deploying my application?
How do i install TOMCAT and JAVA ? can someone provide a link?
I tried doing a remote desktop ut could not connect to the server. Looks like a firewall issue. But then how do i disable ?

Can't answer all your questions, but I'll take a shot.
If you want to watch your ec2 cost, setup a billing alert in AWS that will notify you when your account exceeds a certain threshold, and set your threshold very low if you are very concerend. You can always monitor your outstanding charges on your billing page on a daily basis if you are really concerned.
Pick a small or micro instance if you want to keep your costs low; micro instances I have found are mostly useless for any serious work, but they are very, very cheap and maybe ok for trying things out.
To install any software, you are going to need to get remote desktop working. Once the server is spun up, remote in and you can install anything you want; there is no extra cost to install software (except buying licenses if you need them, but that is not aws's concern, they won't be charging you for installing tomcat.
You need to open up the windows firewall on your 2008 server AND you need to make sure the AWS security group also allows incoming connections on port 3389 - its essentially there firewall that runs in addition to the EC2 instances firewall - BOTH need to be open. You can either modify the security group that was assigned to your instance, or create a new one and associated it with your instance.

Related

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.

Java NTP Implementation

I have a server/client application and I need to synchronize the time of the clients with the time of the server. Thereby I need to implement an NTP Server (or similar) on the server application and an NTP client on the client side.
NTP is not a requirement, but it has to be accurate for at least 50ms (then it would be already a bit critical, but still usable, until I figure out a better solution).
Does anyone have any advices, if there is a good implementation that could help me, or if it's doable to implement this by myself (with the desired precision).
Edit: More information about the project
The server application runs on a customers Home PC. The computer of the customer does not have to change the time, only the client (which is running on a dedicated computer, running on Ubuntu).
This is an IoT project, there are many clients that are very small hardwar devices and should have the same date/time as the server. Because the client won't fiddle with the client's configuration, and he does not have access to it (it's a blackbox), I can run my application using admin rights, if needed.
I don't want to install an NTP Server on my client's home PC. This is the reason I want to deliver this functionality inside of my Java Application.
There's a NtpClient in apache commons-net that you can use for this. You can use this to figure out the clock drift at least of your client pc and try to compensate for that.

Where does the server side of programs run? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
If I had program and multiple clients connecting to a single server where exactly would be a good place to run the server from?
Is there a way to run the server side of the program from a website for example, since websites are servers and could always run the program? Running a server from a home computer doesn't sound like an option that most people would choose because of obvious reasons. For example: where would a small scale indie online game run their server side from?
If I had program and multiple clients connecting to a single server where exactly would be a good place to run the server from?
a computer?
Is there a way to run the server side of the program from a website for example, since websites are servers and could always run the program?
a website is a kind of application run on a server, they are not servers.
Running a server from a home computer doesn't sound like an option that most people would choose because of obvious reasons.
there is no "obvious" reasons why. Many web services started self hosted, and Internet has been built with service providers that are not in datacenters. I do host many services at home and they are accessible from Internet.
For example: where would a small scale indie online game run their server side from?
You have many choices:
a server on a pretty good Internet connection at your home/workplace/garage (with enough bandwidth and low latency),
a virtual server hosted in a datacenter service's provider,
a virtual server like AWS/EC2, Google apps, Azure...
a dedicated server in a datacenter,
a grape of dedicated servers and their caches etc.. with many engineers making the thing work perfectly
...
it all depends on the money you got!
websites are NOT servers. Servers are servers, and host websites (among other things). The "server" is the thing that people connect to, aka a physical machine. This machine may or may not be the same machine as your client.
For an indie game, it depends on your connection. Your options are to either run it yourself out of your room, which is entirely fine provided you have a good internet connection, or to RENT server space, which is some cluster somewhere that you rent access to. These usually have external tech support for when things go wrong.
If you are testing code, run the server software on your local machine. once you get it working, run it on a different computer on your local network. once that works, run it on an external network.
Also, for reference, I run a web/file/computational/etc server out of my bedroom. It keeps me warm in the winter.
A Java web application runs inside an application container such as GlassFish or Tomcat (there are many others). This container runs on a physical server. Typically the physical server will be hosted in a server room of some kind. This can either be at the companies location or, more common for smaller companies, remotely hosted. A remotely hosted server can be a physical piece of hardware you own or more commonly now just a machine you rent, in fact most servers you'd probably rent now will be virtualized.
You can run a web server from a home computer, I've done it for many years, but it has some downsides. You typically have a fairly poor internet connection and a lot of ISP's don't like you hosting servers.
I recommend you look at renting a virtual server.

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.

unreliable behaviour of Openfire server at EC2

We are using openfire server 3.7.1 on Amazon Ec2 linux instance for a chat Application.
Currently, we are in initial development stage, where we are testing it with 4 or 5 concurrent users.
Now, and then we are getting issues with openfire server:
1) Java heap space exceptions.
2) java.net.BindException: Address already in use
3) they both lead to 5222 port not listening, while openfire admin console at 9090 is working fine
Eventually when i stop all openfire processes and then restart it, again it goes to normal.
I want to know, whether this is a bug in openfire version 3.7.1 or EC2 have some issues with opening of port 5222. I am really apprehensive about performance of Openfire server when 1000s user will be using it concurrently?
Solved by:
Disabling PEP.
Increasing Openfire JVM parametres
The Java heap space exception is common to Openfire, you can check your JVM arguments and increase the parameters. In my experience there were a couple of cases that caused those:
clients using Empathy.
some plugin that provided buddy lists/ white/black lists etc (had to do something with the user's roster lists).
You need to make sure port 5222 and 5223 are opened (some clients may use the old SSL port) in EC2 Firewall settings.
If you plan to have thousands of users, I suggest you get static IP address (you don't mention what's your current config). Also checkout jabberd - proved to be more reliable than openfire.
1000s of concurrent users should not be a problem for Openfire at all. It has seen 250K in testing. It will always be determinant though on what the users are doing.
There is a known memory leak in Openfire that has been fixed but not yet released. It is related to PEP, which can be shut off to circumvent this issue if that is feasible for you.

Categories