0

I have a code that connects to a balance, using java socket. The problem is that the connection timeout parameter isn't working properly. No matter what parameter is passed, my waiting time is always 24 seconds.

Is there some sort of parameter on the server I should change?

Here's the part of the code that might interest you.

    int TimeOutConnectionMs = TimeOutConnection.intValue() * 1000;

    socket = new Socket();

    socket.connect(new InetSocketAddress(host, portNumber.intValue()) , TimeOutConnection.intValue() * 1000);

The exceptions used are the following

  } 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);

Thanks for your help

1 Answers1

-1

You are multiplying by 1000 twice, so your actual connect timeout is 1000 times what you think it is.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • No i'm not, the first one is TimeOutConnectionMs ( used later for smthg else ), and the other one is simply TimeOutConnection – Elia Abou Jaoude Jul 25 '16 at 07:51
  • So if it isn't relevant why post it and cause confusion? And y not use it, as it's there, instead of computing the same thing twice? – user207421 Jul 25 '16 at 10:24