【发布时间】:2016-07-25 07:15:24
【问题描述】:
我有一个使用 java 套接字连接到天平的代码。问题是连接超时参数不能正常工作。不管传什么参数,我的等待时间都是24秒。
我应该更改服务器上的某种参数吗?
这是您可能感兴趣的代码部分。
int TimeOutConnectionMs = TimeOutConnection.intValue() * 1000;
socket = new Socket();
socket.connect(new InetSocketAddress(host, portNumber.intValue()) , TimeOutConnection.intValue() * 1000);
使用的异常如下
} catch (SocketTimeoutException e) {
msgException = e.getMessage();
logMessage(process, "EXCEPTION", niveauLog.intValue(), "SocketTimeoutException: " + msgException, host + "_" + portNumber);
} catch (java.net.SocketException e) {
msgException = e.getMessage();
logMessage(process, "EXCEPTION", niveauLog.intValue(), "java net Socket Exception: " + msgException, host + "_" + portNumber);
} catch (java.net.UnknownHostException e) {
msgException = e.getMessage();
logMessage(process, "EXCEPTION", niveauLog.intValue(), "java net Unknown Host Exception: " + msgException, host + "_" + portNumber);
感谢您的帮助
【问题讨论】:
-
从哪里导入
TimeOutConnection?你在使用intValue而不是initValue...你知道吗? -
@JordiCastilla TimeOutConnection 是我从我的 PLSQL 代码接收的参数,我正在使用 intValue() 是的,有什么区别。
-
不知道,我想查看该类的 API 以了解该方法的作用,我想这将解释为什么 24 秒以及使用哪种方法来实现您的目标
-
是socket类,详细在这里:docs.oracle.com/javase/7/docs/api
标签: java timeout timeoutexception