diff --git a/src/com/sheepit/client/Client.java b/src/com/sheepit/client/Client.java index 08a164e..f78982b 100644 --- a/src/com/sheepit/client/Client.java +++ b/src/com/sheepit/client/Client.java @@ -36,6 +36,7 @@ import com.sheepit.client.exception.FermeException; import com.sheepit.client.exception.FermeExceptionNoRightToRender; import com.sheepit.client.exception.FermeExceptionNoSession; import com.sheepit.client.exception.FermeExceptionSessionDisabled; +import com.sheepit.client.exception.FermeServerDown; import com.sheepit.client.os.OS; public class Client { @@ -205,6 +206,18 @@ public class Client { } } } + catch (FermeServerDown e) { + int wait = 15; + int time_sleep = 1000 * 60 * wait; + this.gui.status(String.format("Can not connect to server. Please check your connectivity. Will retry in %s minutes", 15)); + try { + Thread.sleep(time_sleep); + } + catch (InterruptedException e1) { + return -3; + } + continue; // go back to ask job + } catch (FermeException e) { this.gui.error("Client::renderingManagement exception requestJob (1) " + e.getMessage()); StringWriter sw = new StringWriter(); diff --git a/src/com/sheepit/client/Server.java b/src/com/sheepit/client/Server.java index 1ad5e04..434d888 100644 --- a/src/com/sheepit/client/Server.java +++ b/src/com/sheepit/client/Server.java @@ -78,6 +78,7 @@ import com.sheepit.client.exception.FermeException; import com.sheepit.client.exception.FermeExceptionNoRightToRender; import com.sheepit.client.exception.FermeExceptionNoSession; import com.sheepit.client.exception.FermeExceptionSessionDisabled; +import com.sheepit.client.exception.FermeServerDown; import com.sheepit.client.os.OS; public class Server extends Thread implements HostnameVerifier, X509TrustManager { @@ -145,6 +146,9 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager } } } + catch (NoRouteToHostException e) { + this.log.debug("Server::keeepmealive can not connect to server"); + } catch (IOException e) { e.printStackTrace(); } @@ -434,6 +438,9 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager catch (FermeException e) { throw e; } + catch (NoRouteToHostException e) { + throw new FermeServerDown(); + } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); diff --git a/src/com/sheepit/client/exception/FermeServerDown.java b/src/com/sheepit/client/exception/FermeServerDown.java new file mode 100644 index 0000000..00f3295 --- /dev/null +++ b/src/com/sheepit/client/exception/FermeServerDown.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2015 Laurent CLOUET + * Author Laurent CLOUET + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; version 2 + * of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package com.sheepit.client.exception; + +/** + * Server down (server side error) or unreachable (client side error) + * + */ +public class FermeServerDown extends FermeException { + public FermeServerDown() { + super(); + } + + public FermeServerDown(String message_) { + super(message_); + } +}