我目前正在使用 ch.ethz.ssh2.Connection 连接到我在 java 中的服务器。有时它会挂在一台服务器上。(可能需要 10-15 秒)。我想知道是什么导致了这个挂起时间以及如何避免它。
连接示例
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?