【发布时间】:2017-11-18 03:35:20
【问题描述】:
我目前正在使用 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?
【问题讨论】:
-
它总是/经常是同一个服务器还是不同?
-
@Robert 主要在相同的服务器上,但有所不同。另外,对于您之前的线程池示例,是否有最大限制?