超时连接无法正常工作-Java

超时连接无法正常工作-Java,java,timeout,timeoutexception,Java,Timeout,Timeoutexception,我有一个使用java套接字连接到天平的代码。问题是连接超时参数工作不正常。无论传递什么参数,我的等待时间总是24秒 服务器上是否有某种参数需要更改 下面是您可能感兴趣的代码部分 int TimeOutConnectionMs = TimeOutConnection.intValue() * 1000; socket = new Socket(); socket.connect(new InetSocketAddress(host, portNumber.intValu

我有一个使用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);

感谢您的帮助

您将乘以1000倍,因此您的实际连接超时是您认为的1000倍。

从哪里导入
TimeOutConnection
?您是否正在使用
int
Value
而不是
initValue
。。。你知道吗?@JordiCastilla TimeOutConnection是我从PLSQL代码中收到的一个参数,我正在使用intValue()是的,有什么区别。不知道,我想检查类的API以了解该方法的作用,我想这将解释为什么24秒以及使用哪个方法来实现你的目标是socket类,详细信息如下:不,我不是,第一个是TimeOutConnectionMs(稍后用于smthg else),另一个只是timeoutconnections。如果它不相关,为什么要发布它并引起混淆?你不使用它,因为它在那里,而不是计算相同的东西两次?