garry has asked for the wisdom of the Perl Monks concerning the following question:

I have a Perl SOAP::Lite client and server. I specify keep_alive in the client, but the client closes the connection after the server responds with Keep-Alive. Here's the client code:
use warnings; use strict; use SOAP::Lite; my $som = SOAP::Lite->uri('http://my_namespace/SOAP_ImageMgr') ->proxy('http://wshost/cgi-bin/imagemgr/imagemgr', timeout => 30, keep_alive => 1); my $url = 'http://image-url/'; for (1 .. 100) { my $resp = $som->get_image_token($url, 260, 260); if ($resp->fault()) { die("$0: can't get image handle for $url(260): ", $resp->faultstring(), "\n"); } print $resp->result(), "\n"; }
I have a tcpdump that shows a close from the client after each response from the server; then a brand new connection is opened for the next request. My server is a simple dispatch to an in-line package. How do I get the client to use the open connection instead of closing and re-opening?
$ perl -v This is perl, v5.8.3 built for x86_64-linux-thread-multi $ perl -MSOAP::Lite -wle 'print $SOAP::Lite::VERSION' 0.60 $ perl -MLWP::UserAgent -wle 'print $LWP::UserAgent::VERSION' 2.033 $ perl -MLWP::ConnCache -wle 'print $LWP::ConnCache::VERSION' 0.01 $

Replies are listed 'Best First'.
Re: SOAP::Lite Client Closes Keep-Alive Connection
by InfiniteSilence (Curate) on Feb 06, 2006 at 21:54 UTC
    Are you using Apache and have you set the Keep-Alive directive?

    Celebrate Intellectual Diversity

      Apache.
      KeepAlive 100 KeepAliveTimeout 15
      The tcpdump shows a proper response with these values set in the Keep-Alive: header and the Connection: header says "Keep-Alive".
        I found this (2 years after the post, but maybe it will help others) I'm using SOAP::Lite 0.71, and it works setting this variable: $SOAP::Constants::PATCH_HTTP_KEEPALIVE=0; Its almost documented in SOAP::Constants So the code should be something like: $SOAP::Constants::PATCH_HTTP_KEEPALIVE=0; my $soap= SOAP::Lite -> readable(1) # Opcion de debug para ver mas lindo el XML -> ns('Hello') -> proxy($PROXY, keep_alive => 1, timeout => 30 ); print $soap -> sayHello($name) -> result . "\n\n"; :