JTOpen 程序调用套接字超时
JTOpen ProgramCall Socket Timeout
我正在开发一个 Web 应用程序(运行 on Tomcat),它使用 JTOpen ProgramCall class( com.ibm.as400.access.ProgramCall).我的问题是程序调用需要超过 30 秒才能响应,这会触发 java.net.SocketTimeoutException: Read timed out exception
.
有一个 setTimeout()
方法可用于此 class,但它似乎对套接字超时没有影响。我还检查了我的 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());
}
嗯,又过了几个小时,我找到了解决方案。显然,最初的开发人员向 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();
:\
我正在开发一个 Web 应用程序(运行 on Tomcat),它使用 JTOpen ProgramCall class( com.ibm.as400.access.ProgramCall).我的问题是程序调用需要超过 30 秒才能响应,这会触发 java.net.SocketTimeoutException: Read timed out exception
.
有一个 setTimeout()
方法可用于此 class,但它似乎对套接字超时没有影响。我还检查了我的 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());
}
嗯,又过了几个小时,我找到了解决方案。显然,最初的开发人员向 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();
:\