diff --git a/Mage.Client/src/main/java/mage/client/dialog/ConnectDialog.java b/Mage.Client/src/main/java/mage/client/dialog/ConnectDialog.java index 0f054ccace..4cebda9f5e 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/ConnectDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/ConnectDialog.java @@ -54,6 +54,8 @@ import java.util.Arrays; import java.util.List; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; /** * @author BetaSteward_at_googlemail.com @@ -321,6 +323,8 @@ public class ConnectDialog extends MageDialog { private boolean result = false; + private static final int CONNECTION_TIMEOUT_MS = 2100; + @Override protected Boolean doInBackground() throws Exception { lblStatus.setText("Connecting..."); @@ -332,7 +336,7 @@ public class ConnectDialog extends MageDialog { @Override protected void done() { try { - get(); + get(CONNECTION_TIMEOUT_MS, TimeUnit.MILLISECONDS); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); if (result) { lblStatus.setText(""); @@ -348,8 +352,10 @@ public class ConnectDialog extends MageDialog { } catch (CancellationException ex) { logger.info("Connect was canceled"); lblStatus.setText("Connect was canceled"); - MageFrame.stopConnecting(); + } catch (TimeoutException ex) { + logger.fatal("Connection timeout: ", ex); } finally { + MageFrame.stopConnecting(); btnConnect.setEnabled(true); } } diff --git a/Mage.Common/src/mage/remote/SessionImpl.java b/Mage.Common/src/mage/remote/SessionImpl.java index 5b6e24fd55..346b12858e 100644 --- a/Mage.Common/src/mage/remote/SessionImpl.java +++ b/Mage.Common/src/mage/remote/SessionImpl.java @@ -36,6 +36,7 @@ import mage.cards.repository.CardRepository; import mage.cards.repository.ExpansionInfo; import mage.cards.repository.ExpansionRepository; import mage.constants.Constants.SessionState; +import mage.constants.ManaType; import mage.game.GameException; import mage.game.match.MatchOptions; import mage.game.tournament.TournamentOptions; @@ -56,7 +57,6 @@ import org.jboss.remoting.transporter.TransporterClient; import java.net.*; import java.util.*; -import mage.constants.ManaType; /** * @@ -159,6 +159,8 @@ public class SessionImpl implements Session { * the server, and on the server side an org.jboss.remoting.Lease informs registered listeners * if the PING doesn't arrive withing the specified timeout period. */ clientMetadata.put(Client.ENABLE_LEASE, "true"); + clientMetadata.put("numberOfCallRetries", "1"); + // Indicated the max number of threads used within oneway thread pool. clientMetadata.put(Client.MAX_NUM_ONEWAY_THREADS, "10"); clientMetadata.put(Remoting.USE_CLIENT_CONNECTION_IDENTITY, "true");