LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Lavastorm: TRY-CATCH for Http timeouts

    Employee
    Posted 07-19-2017 09:50

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: rgvenkatesh

    Hi,

    Is it possible to use the try/catch approach to catch a HttpNode timeout exception (Probably a Http Library node which lets us use Java code).

    Looking to build a logic as shown below into a Lavastorm. Expectation is to handle timeouts without the Node aborting (failing with a Red cross).

    try
    {
    // Create a DataInputStream for reading from socket
    DataInputStream din = new DataInputStream (connection.getInputStream());
    // Read data until end of data
    for (;
    {
    String line = din.readLine();
    if (line != null)
    System.out.println (line);
    else
    break;
    }
    }
    // Exception thrown when network timeout occurs
    catch (InterruptedIOException iioe)
    {
    System.err.println ("Remote host timed out during read operation");
    }



    Regards,
    Venkatesh


  • 2.  RE: Lavastorm: TRY-CATCH for Http timeouts

    Employee
    Posted 07-19-2017 11:12

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: stonysmith

    You could do that in a custom Python or Java node, but not in BrainScript, purely because BrainScript doesn't support Sockets.


  • 3.  RE: Lavastorm: TRY-CATCH for Http timeouts

    Employee
    Posted 07-19-2017 17:07

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: prasmussen

    Are you writing/modifying an existing java node or trying to use the out of the box HTTP node?

    If writing/modifying a node with java, there are multiple ways to either a)set the timeout or b)catch the timeout and ignore it. See the following for further detail on the custom java solution to catch the java.net.SocketTimeoutException. https://stackoverflow.com/questions/...efined-timeout All you would need to do is add the catch and gracefully exit the node without an error.

    If using the out of the box node, there's a parameter for connection timeout.


  • 4.  RE: Lavastorm: TRY-CATCH for Http timeouts

    Employee
    Posted 07-20-2017 11:33

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: rgvenkatesh

    Thanks for the replies.

    As mentioned by stonysmith, HTTP node only provides a timeout parameter to define a caller side timeout but to handle the timeouts on client side more gracefully would need to customize the java node and handle timeouts as an exception there.