我有一个使用java套接字连接到天平的代码。问题是连接超时参数无法正常工作。无论通过什么参数,我的等待时间都是24秒。超时连接无法正常工作 - Java
我应该改变服务器上的某种参数吗?
以下是您可能感兴趣的部分代码。
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'?你使用**'int' **'Value'而不是'initValue' ...你知道这个吗? –
@JordiCastilla TimeOutConnection是我从我的PLSQL代码收到的参数,我使用intValue()是,有什么不同。 –
不知道,我想检查该类的API知道该方法做什么,我认为这将解释为什么24秒和哪种方法用于实现您的目标 –