Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 209
Adroidist Avatar asked Dec 16 '22 23:12

Adroidist


1 Answers

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.

like image 78
Barak Avatar answered Feb 07 '23 14:02

Barak