Unable to resolve host "mywebsite.com": No address associated with hostname - java

I have an android application where I send http requests to an api via Retrofit2/OkHttp. Everything was working fine for 2 weeks. 2 days ago my site was suspended. It reopened today.Error messages started to appear from some users. Users say "Unable to login to the application!". When I checked the logs, I saw something like this ;
I/okhttp.OkHttpClient: <-- HTTP FAILED: java.net.UnknownHostException: Unable to
resolve host "mywebsite.com": No address associated with hostname
Some users are still able to login to the application.I can't make sense of this.
How can I fix this immediately?

Sounds like your mywebsite.com DNS has just not been propagated out fully yet. Check with your hosting service on how long that can take.
For instance, this is what one web hosting service says about it:
https://www.hostgator.com/help/article/when-will-my-domain-start-working-propagation

Related

Same public ip address is returned in java

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.

unable to access web application deployed on azure container service

I am trying out azure container services with docker swarm as orch. i am an aws guy and completely new to azure and it has been really tough to get it to work so far.
i followed the azure dashboard to create a container service which created a resource group. i was able to tunnel in to the swarm-master and run docker commands on the swarm-master. the containers launched successfully too but im unable to access the deployed web app. i tried 80 and 8080 ports. i tried pinging the public IP and dns of the swarm-agent, the pings timed out with message Request timeout for icmp_seq 0 in aws similar issues can be resolved by setting inbound security rules but in azure it seemed like they are already set. Can someone please tell me if im missing something.
following is the guide i followed:https://www.youtube.com/watch?v=-wjxpng6jYs
Please try looking at this guide: https://blogs.msdn.microsoft.com/jcorioland/2016/04/25/create-a-docker-swarm-cluster-using-azure-container-service/
The service should be available by accessing the service port on the agent's load balancer's public ip.
If it's not running on port 80, you need to open NSG ports manually.
Please offer more details about the steps you've taken exactly if this doesn't unblock you. What container image? Why are you trying both 80 and 8080? Etc.

Strange RMI connection exception with Amazon EC2

I know this is something repetead but couldn't find the solution to my problem...
I am trying to implement a simulated distributed system and I struggling a lot with the connectivity through RMI.
I have three different components, grid schedulers, resources managers and clients. The three of them interact among themselves. The behaviour is the following: the user looks up resource manager reference on the registry and then invokes a remote method which will invoke another one in the grid scheduler and eventually one method in the user will be invoked delivering the results. If I execute the whole system in local everything works as expected.
Now the thing is, I am trying to move one of the resource mananger nodes to a EC2 Amazon instance with public address A.A.A.A, the rest of the system will run locally on my laptop with public address B.B.B.B. I allowed TCP traffic on the port 1099 TCP/UDP on the security group policy, also set the java.security.policy to grant all permision in both machines. To create the registry in every component I do:
LocateRegistry.createRegistry(1099);
Then the components will discover themselves by
Naming.lookup(url)
Now, user will look up for ip address A.A.A.A/component the public address of the Amazon instance. I can check that sometimes it gets the reference, sometimes it doesn't (NotBoundException). However, when it does gets the reference and tries to call the method I get:
java.rmi.ConnectException: Connection refused to host: INTERNAL IP OF AMAZON INSTANCE nested exception is: java.net.ConnectException: Connection timed out: connec.
Am I doing something wrong? I tried to set the property
java.rmi.server.hostname
To the public ip A.A.A.A in the Amazon instance and I got same results. I also tried doing the same on my laptop to the public address B.B.B.B and I got "connection refused IP B.B.B.B is not a localhost address"
I also opened the port in the router of my houe just in case that's the problem but it doesn't seem to be...
Am I missing something?
Thanks in advance.
Okay apparently, the issue was that even if the server listens on port 1099 then the port you use to connect the stub is random so I had to open all TCP ports in the security group of AWS. In that way it's working, however even if I turned off my windows firewall and open all the ports in the router it wasn't working my laptop - AWS, just different instances in AWS. But well, I can live with that...
Regarding the hostname you have to set it to the private address returned by
hostname -i
If you're going to deploy it inside AWS or to the public IP if you're connecting different instances such as your laptop and one EC2.
I hope this helps people on the same situation (have seen couple of questions with the same issue but no response).
Have a nice day!

Checking if device is connected to certain network

How can I check if my Android application is able to connect to a certain host? For example, I can make a HTTP GET call from a company web service if I am connected to the company network. If I am not on the company network (router, etc.) I can't make the HTTP GET call and it says "Unable to resolve host : No address associated with hostname". How do I check if the wifi or data is within the company?
That error means you don't have an IP related to the domain you want to surf. There is something wrong with DNS.
Try to use nslookup to check your connection with host you want to visit and then check if HTTP GET returns error.

Login with local access with ip

For an assigment I have a server with Tomcat 6. On this server we made a website where you can log in. The problem is that we don't to log in on the website if you work local and we don't know how to do that.
We've tried to google on it and we found to use "x-forwarded-for", but that doesn't work. Then you don't need to log in at all (extern too).
I hope you guys can help me!
Get the request which is a ServletRequest instance (you might have to cast it) and call getRemoteAddr() on it.
JavaDoc on that method:
Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
Locally you should get the ip 127.0.0.1. Additionally you might also want to check whether the request ip is the server's local ip.

Categories

Resources