我目前使用ch.ethz.ssh2.Connection連接到我在java中的服務器。有時會掛在一臺服務器上(可能需要10-15秒)。我想知道是什麼原因導致了這個掛機時間,以及如何避免這種掛機。什麼原因導致ch.ethz.ssh2.Connection掛起時間?
連接樣品
conn = new ch.ethz.ssh2.Connection(serverName);
conn.connect();
boolean isAuthenticated = conn.authenticateWithPassword(user, pass);
logger.info("Connecting to " + server);
if (isAuthenticated == false) {
logger.info(server + " Please check credentials");
}
sess = conn.openSession();
// I am connecting to over 200 servers and closing them. What would be the best practice to loop thru all these servers in the minimal time.
//some servers quickly connects, while some takes some time.
why does this happen?
它總是/通常是相同的服務器還是它有所不同? – Robert
@羅伯特大多在同一臺服務器上,但各不相同。此外,你的例子早些時候用於線程池是否有最大限制? – Jesse