I am working with Alfresco and sometimes the server is down for low space or other problem , the thing is with my serverURL i want to check if he is available (Alfresco Server) i thought to make a ping but the adresse is to complexe for a simple ping ex : http://127.0.0.1:8084/alfresco/api/-default-/public/cmis/versions/1.0/atom
I am working in a J2EE Project
Asked
Active
Viewed 364 times
0

Yagami Light
- 1,756
- 4
- 19
- 39
-
1Would `/alfresco/service/api/server` work? Or do you need to check that writes succeed? – Gagravarr Jul 21 '16 at 14:04
-
I tried it and it said java.net.UnknownHostException i used http://127.0.0.1/alfresco/service/api/server – Yagami Light Jul 21 '16 at 14:13
-
You need to give the port, and either give the public IP of the machine OR run the check from the machine itself – Gagravarr Jul 21 '16 at 14:17
-
I tried it with the port and it is the same **java.net.UnknownHostException** – Yagami Light Jul 21 '16 at 14:21
-
Without knowing the code you're using to do the fetch it's hard to help you, but most likely you're stuffing that bit up... – Gagravarr Jul 21 '16 at 16:56
-
Thank you @Gagrvarr it is the right path to see if it's working i will post the answer (the code) – Yagami Light Jul 23 '16 at 10:05
1 Answers
0
Hi i want to say that the part of the answer where given by @Gagravarr
public void pingADR() throws UnknownHostException, IOException {
String url = "http://127.0.0.1:8084/alfresco/service/api/server";
String status = getStatus(url);
System.out.println(url + "\t\tStatus:" + status);
}
and to see if it's available
public static String getStatus(String url) throws IOException {
String result = "";
try {
URL siteURL = new URL(url);
HttpURLConnection connection = (HttpURLConnection) siteURL
.openConnection();
connection.setRequestMethod("GET");
connection.connect();
int code = connection.getResponseCode();
if (code == 200) {
result = "Green";
}
} catch (Exception e) {
result = "->Red<-";
}
return result;
}
I found this answer in a very helpful web site, Hope that will help other people

Yagami Light
- 1,756
- 4
- 19
- 39