I'm trying to write a client/server application with the server side being hosted on an Amazon EC2 server running Ubuntu. The server works locally, but I can't seem to get it to work on the EC2. I can tell that it's opening a port, as it's supposed to, by using netstat. However, every time I try to connect, the Client program catches an IOException.
The way I'm getting the IP address of the server is from the Public DNS address given by Amazon. I'm assuming that if Amazon gives you ec2-XX-XXX-XXX-XXX.us-west-2.compute.amazonaws.com then XX.XXX.XXX.XXX is the public IP address. Is this correct? Or am I doing something wrong?
Any help is appreciated!
Related
In my project I need to find the public ip address of a machine.
I have implemented that using method mentioned in Finding public ip address using java
I have an api url like 'http://182.14.10.5:8080/test/addVendor' (not exact url) in my project and has been deployed in external tomcat server which has public ip address as 187.15.161.90.
The issue am facing is:
When i tried loading this api url from other devices like mobile or computers belong to some other network, am getting the same ip 182.14.161.90 for every URL hit.
This is where i got confused. Whether the program is written according to that or am i getting wrong output.
According to the search results what I understood is, when I load the particular api url, I should get different ip address based on different machine connected with different network.
But am getting the same public ip (182.14.161.90) of the server where my project is deployed.
Can anyone pls clarify it and help me to fix the issue.
Any suggestions would be appreciated.
Thanks
It sounds to me like you have a Java Web Application deployed via tomcat and want to get a user's IP address.
The question you've linked in your question Finding public ip address using java is specifically for getting the IP address of the machine where the Java Code is running (for example, if you have a desktop application and want to get the IP of the machine that app is running on for some reason)
If you want to get the user's remote IP, it depends on your server configuration
If Tomcat is the ONLY webserver in your environment, and there is nothing in front of it, you can access the Request's remote ip using HttpServletRequest#getRomoteAddr, which will give you the IP address of the socket connection that initiated the Request.
This will work great unless you have a proxy server, like Apache HTTPD or Nginx in front of Tomcat, in which case you'll need to configure your server to send the
X-Forwarded-For header, and get the user's remote IP using HttpServletRequest#getHeader for example, request.getHeader("X-Forwarded-For")
If I've misunderstood your question, please clarify and let me know with a comment.
I'm doing a project, I have a server, a client (C #), a client (Android java). I can connect to the server on the local network and use an external ip from the client C #, but from the Java client I can connect only by Wifi. The server on the router port forwarding, I have a static ip address. Help please what's the problem?
From the info you provided, there is nothing wrong.
For your C# client, you can connect it from local network (i assume 192.168.x.x)
and
For your java client, using wifi means local network (also i assumed 192.168.x.x)
so it means that it works well with local network.
So now the main problem is, is your server really online to internet
Please check the following:
Is your server accessible via any api testing tools, such as RESTFUL AND SOAPUI using external ip address.
Is you android client really online when not using a local network, or you can access it through external ip address.
I've implemented a simple ZeroMQ (0MQ) server and client. It works well when I use them on a machine (local). But when I run the client on one another machine, it doesn't work (it cannot connect to the remote server). I've checked my firewall and it's inactive (in Ubuntu 14.04).
My server code written in java is:
ZMQ.Socket responder = context.socket(ZMQ.REP);
responder.bind("tcp://*:5555");
and the client code:
requester.connect("tcp://ipaddress:5555");
in which "ipaddress" is the IP address of my server.
I've tried also different port numbers.
Please, explain what is the problem and what do you suggest to solve the problem??
Thanks in advance
I am trying to connect to a virtual machine using sockets in Java. I have my client and server applications working with no issues on localhost. When I run the Server code and try to connect from a separate machine with the IP address and port number, my client connection times out.
Here is a link to my virtual machine network settings page https://wiki.redbrick.dcu.ie/mw/RBVM_Networking
Do I need to specify any particular parameters in Java to make my server accept connections? Is this an issue I have to take up with the VM network admins?
Any suggestions would be appreciated !
p.s I am running ubuntu server and can access phpmyadmin remotely with no problems.
Edit
I have run nmap and the port I am using for the server side application shows up as open.
My provider was blocking all but a select few ports, got a list of open ones and now it works. derp!
I am trying to look the web application I made with Java EE. The server and database is up and running. It works on localhost:8080, but when I replace localhost with the local IP address all I get is a 404 error. Do I need to configure something?
On windows 7 open the firewall to allow incoming and outgoing traffic on port 8080. Then from the remote machine make sure that you can ping the server's ip address and then try to browse to the address.