diff --git a/src/main/java/net/schmizz/sshj/connection/ConnectionImpl.java b/src/main/java/net/schmizz/sshj/connection/ConnectionImpl.java index 1005a859..fef11ee4 100644 --- a/src/main/java/net/schmizz/sshj/connection/ConnectionImpl.java +++ b/src/main/java/net/schmizz/sshj/connection/ConnectionImpl.java @@ -63,7 +63,7 @@ public class ConnectionImpl */ public ConnectionImpl(Transport trans) { super("ssh-connection", trans); - timeoutMs = trans.getTimeout() * 1000; + timeoutMs = trans.getTimeoutMs(); } @Override diff --git a/src/main/java/net/schmizz/sshj/transport/KeyExchanger.java b/src/main/java/net/schmizz/sshj/transport/KeyExchanger.java index 247fd32c..5f33e739 100644 --- a/src/main/java/net/schmizz/sshj/transport/KeyExchanger.java +++ b/src/main/java/net/schmizz/sshj/transport/KeyExchanger.java @@ -155,7 +155,7 @@ final class KeyExchanger * @param waitForDone whether should block till key exchange completed * * @throws TransportException if there is an error during key exchange - * @see {@link Transport#setTimeout} for setting timeout for kex + * @see {@link Transport#setTimeoutMs} for setting timeout for kex */ void startKex(boolean waitForDone) throws TransportException { @@ -169,7 +169,7 @@ final class KeyExchanger void waitForDone() throws TransportException { - done.await(transport.getTimeout(), TimeUnit.SECONDS); + done.await(transport.getTimeoutMs(), TimeUnit.MILLISECONDS); } private synchronized void ensureKexOngoing() @@ -360,7 +360,7 @@ final class KeyExchanger * We block on this event to prevent a race condition where we may have received a SSH_MSG_KEXINIT before * having sent the packet ourselves (would cause gotKexInit() to fail) */ - kexInitSent.await(transport.getTimeout(), TimeUnit.SECONDS); + kexInitSent.await(transport.getTimeoutMs(), TimeUnit.MILLISECONDS); gotKexInit(buf); expected = Expected.FOLLOWUP; break; diff --git a/src/main/java/net/schmizz/sshj/transport/Transport.java b/src/main/java/net/schmizz/sshj/transport/Transport.java index 20dc92ff..ede61685 100644 --- a/src/main/java/net/schmizz/sshj/transport/Transport.java +++ b/src/main/java/net/schmizz/sshj/transport/Transport.java @@ -86,14 +86,14 @@ public interface Transport Config getConfig(); /** @return the timeout that is currently set for blocking operations. */ - int getTimeout(); + int getTimeoutMs(); /** * Set a timeout for methods that may block. * - * @param timeout the timeout in seconds + * @param timeout the timeout in milliseconds */ - void setTimeout(int timeout); + void setTimeoutMs(int timeout); /** @return the interval in seconds at which a heartbeat message is sent to the server */ int getHeartbeatInterval(); diff --git a/src/main/java/net/schmizz/sshj/transport/TransportImpl.java b/src/main/java/net/schmizz/sshj/transport/TransportImpl.java index 289a4430..d2486846 100644 --- a/src/main/java/net/schmizz/sshj/transport/TransportImpl.java +++ b/src/main/java/net/schmizz/sshj/transport/TransportImpl.java @@ -113,7 +113,7 @@ public final class TransportImpl /** Client version identification string */ private final String clientID; - private volatile int timeout = 30; + private volatile int timeoutMs = 30 * 1000; // Crazy long, but it was the original default private volatile boolean authed = false; @@ -241,13 +241,13 @@ public final class TransportImpl } @Override - public int getTimeout() { - return timeout; + public int getTimeoutMs() { + return timeoutMs; } @Override - public void setTimeout(int timeout) { - this.timeout = timeout; + public void setTimeoutMs(int timeoutMs) { + this.timeoutMs = timeoutMs; } @Override @@ -311,7 +311,7 @@ public final class TransportImpl try { serviceAccept.clear(); sendServiceRequest(service.getName()); - serviceAccept.await(timeout, TimeUnit.SECONDS); + serviceAccept.await(timeoutMs, TimeUnit.MILLISECONDS); setService(service); } finally { serviceAccept.unlock();