In my opinion in order to achieve this you have to check your proxy server is alive or not by using following piece of code.
If boolean variable conectionStatus is true your server is alive.
public boolean testConnection() {
boolean connectionStatus=false;
try {
InetAddress addr=InetAddress.getByName("8.8.8.8");//here type proxy server ip
connectionStatus=addr.isReachable(1000); // 1 second time for response
}
catch (Exception e) {
e.printStackTrace();
System.out.println(e.toString());
}
return connectionStatus;
}