我正在开发一个web应用程序(运行在Tomcat上),它使用JTOpen ProgramCall类(com.ibm.as400.access.ProgramCall)调用IBM上的程序(AS/400)。我的问题是,程序调用需要30多个才能响应,这会触发一个java.net.SocketTimeoutException: Read timed out exception。
这个类有一个可用的setTimeout()方法,但它似乎对套接字超时没有影响。我也检查了我的Tomcat配置,没有看到任何可能导致这种行为的东西。
有人知道如何改变这种实现的超时吗?
代码:
pgmCall.setProgram(getCompleteName(), parmList);
initializeAS400TextParameters();
// Run the AS/400 program.
try {
Trace.setTraceDiagnosticOn(true);
Trace.setTraceInformationOn(true);
Trace.setTraceWarningOn(true);
Trace.setTraceErrorOn(true);
Trace.setTraceDatastreamOn(true);
if (pgmCall.run() != true) {
messageList = pgmCall.getMessageList();
for (int i = 0; i < messageList.length; i++) {
log.debug("Error Message " + i + " " + messageList[i]);
}
setCompletionMsg("Program call failed.");
log.debug("442 Program call failed.");
return false;
} else {
messageList = pgmCall.getMessageList();
for (int i = 0; i < messageList.length; i++) {
log.debug("Success Message " + i + " " + messageList[i]);
}
setCompletionMsg("Program called ok.");
log.debug("452 Program called ok.");
return true;
}
} catch (Exception e) {
// This is where the timeout exception is thrown
log.debug("Error Running Program: " + e.getMessage() + " " + e.getLocalizedMessage());
setCompletionMsg(e.getMessage());
}发布于 2016-04-04 21:49:27
几个小时后我找到了解决办法。显然,最初的开发人员在JDBC连接字符串中添加了一个socket timeout参数--只要删除这个参数就可以了,因为默认值是0,或者说是无限超时。
在此之前:
String connectionStr = "jdbc:as400://" + systemInfo.getIPAddress() + ":1527" + ";naming=system;socket timeout=30000;thread used=false;errors=full;prompt=false;date format=iso;block size=128;transaction isolation=none;user=" + systemInfo.getUserName() + ";password=" + systemInfo.getPassword();
之后:
String connectionStr = "jdbc:as400://" + systemInfo.getIPAddress() + ":1527" + ";naming=system;thread used=false;errors=full;prompt=false;date format=iso;block size=128;transaction isolation=none;user=" + systemInfo.getUserName() + ";password=" + systemInfo.getPassword();
*\
https://stackoverflow.com/questions/36362402
复制相似问题