Loading ...
Sorry, an error occurred while loading the content.

SOAP::Lite timeout issue?

Expand Messages
  • Dominick Meglio
    Hello, I am attempting to test my SOAP::Lite client in various error conditions. One such condition is when the SOAP server cannot be reached (i.e., a
    Message 1 of 2 , Jul 12, 2005
    • 0 Attachment
      Hello, I am attempting to test my SOAP::Lite client in various error
      conditions. One such condition is when the SOAP server cannot be
      reached (i.e., a connection timeout occurs).

      I have set a timeout for the object:
      my $soap = SOAP::Lite->uri($uri)->proxy($proxy, timeout => 10);

      As I understand it, this should make a timeout occur after 10 seconds.

      Next is my method call:

      $soap->runner($para);

      Since the server is not running, this will cause a connection timeout.
      After 3 minutes (not 10 seconds), I receive a message:

      500 Connect failed: connect: Connection timed out; Connection timed out

      Also, it is important to note that if the method call is NOT in an
      eval {};, then I get an exception when the timeout occurs (something I
      cannot find documented anywhere).

      My question is, how do I get the connect attempt to stop if my
      specified timeout has elapsed, and simply allow me to detect the error
      condition and allow my program to continue on?

      Thanks in advance,
      Dominick Meglio
    • Mark Fuller
      ... I don t know what the correct answer is regarding S::L s handling of client connection timeouts. But, as a workaround, you should be able to set an alarm
      Message 2 of 2 , Jul 12, 2005
      • 0 Attachment
        --- Dominick Meglio <dmeglio@...> wrote:

        > My question is, how do I get the connect attempt to
        > stop if my
        > specified timeout has elapsed, and simply allow me
        > to detect the error
        > condition and allow my program to continue on?

        I don't know what the correct answer is regarding
        S::L's handling of client connection timeouts. But, as
        a workaround, you should be able to set an alarm
        within your eval and trap it. You need a signal
        handler for the alarm. I had an example of doing this
        with something else. I'd have to look for it. (It is a
        little trickier than it sounds because there's a race
        condition between the inner alarm and the outer eval.
        Something like that.)

        As far as eval'ing to trap fatal errors. I think
        that's relatively common. I know I had to do it with
        ssh::sftp. I didn't think it was too cumbersome. I had
        to accomodate for what may be multiple errors within
        an eval and that $@ will have the last error (which
        may not be as informative as earlier errors). I
        handled this with a signal handler to capture every
        warning event. I added each warning message to an
        array each time the signal handler was invoked. In the
        end, I had an array of messages (if multiple errors
        occured).

        =====
        my @warnings;

        $SIG{"__WARN__"} = sub { $warnings[$#warnings + 1] =
        $_[0]; };

        eval {$my_result = $object->function(".");};

        $SIG{"__WARN__"} = "DEFAULT";

        if ($#warnings > -1 or (!defined($pwd) or $pwd eq "")
        ) {
        # treat it as an error, display each row of @array
        }
        ======

        Maybe that would be useful to you?

        Mark




        __________________________________
        Yahoo! Mail for Mobile
        Take Yahoo! Mail with you! Check email on your mobile phone.
        http://mobile.yahoo.com/learn/mail
      Your message has been successfully submitted and would be delivered to recipients shortly.