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

I'm trying to get LWP::Parallel::UserAgent to work with perlapp or perl2exe on WinXP. When script below is runned from command-console, everything works fine.

Once the script gets "compiled" with perlapp or perl2exe, the script just refuses to connect and bring home any data..

Below is some of the output from the test script when runned with "use debug"-option on and compiled with perlapp:

LWP::UserAgent::new: () LWP::Parallel::UserAgent::register: (http://www.cnn.com, CODE(0xd91f90 +), [undef] , [undef]) LWP::Parallel::UserAgent::register: (http://www.sun.com, CODE(0xd91f90 +), [undef] , [undef]) LWP::Parallel::UserAgent::register: (http://www.msn.com, CODE(0xd91f90 +), [undef] , [undef]) LWP::Parallel::UserAgent::register: (http://www.sun.com, CODE(0xd91f90 +), [undef] , [undef]) LWP::Parallel::UserAgent::register: (http://www.bbc.co.uk, CODE(0xd91f +90), [unde f], [undef]) LWP::Parallel::UserAgent::wait: Current Server: 0 [ ] Pending Server: 4 [ www.msn.com:80, 1, www.cnn.com:80, 1, www. +sun.com:80 , 2, www.bbc.co.uk:80, 1 ] LWP::Parallel::UserAgent::_make_connections_unordered: () LWP::Parallel::UserAgent::_check_bandwith: (LWP::Parallel::UserAgent:: +Entry=HASH (0xe114a4) [http://www.msn.com] ) LWP::Parallel::UserAgent::on_connect: (http://www.msn.com) LWP::Parallel::UserAgent::_connect: (LWP::Parallel::UserAgent::Entry=H +ASH(0xe114 a4) [http://www.msn.com] ) LWP::Parallel::UserAgent::init_request: -> (HTTP::Request=HASH(0xe0f96 +0)) [GET h ttp://www.msn.com] LWP::Parallel::UserAgent::init_request: GET http://www.msn.com LWP::UserAgent::_need_proxy: Not proxied LWP::Parallel::UserAgent::on_failure: (http://www.msn.com) LWP::Parallel::UserAgent::_check_bandwith: Failed connection for 'www. +msn.com:80 ' LWP::Parallel::UserAgent::_make_connections_unordered: Queue for www.m +sn.com:80 contains 0 pending connections LWP::Parallel::UserAgent::_check_bandwith: (LWP::Parallel::UserAgent:: +Entry=HASH (0xe0f768) [http://www.cnn.com] ) LWP::Parallel::UserAgent::on_connect: (http://www.cnn.com) LWP::Parallel::UserAgent::_connect: (LWP::Parallel::UserAgent::Entry=H +ASH(0xe0f7 68) [http://www.cnn.com] ) LWP::Parallel::UserAgent::init_request: -> (HTTP::Request=HASH(0xa0c23 +c)) [GET h ttp://www.cnn.com] LWP::Parallel::UserAgent::init_request: GET http://www.cnn.com LWP::UserAgent::_need_proxy: Not proxied LWP::Parallel::UserAgent::on_failure: (http://www.cnn.com) LWP::Parallel::UserAgent::_check_bandwith: Failed connection for 'www. +cnn.com:80 ' LWP::Parallel::UserAgent::_make_connections_unordered: Queue for www.c +nn.com:80 contains 0 pending connections LWP::Parallel::UserAgent::_check_bandwith: (LWP::Parallel::UserAgent:: +Entry=HASH (0xe0fa08) [http://www.sun.com] ) LWP::Parallel::UserAgent::on_connect: (http://www.sun.com) LWP::Parallel::UserAgent::_connect: (LWP::Parallel::UserAgent::Entry=H +ASH(0xe0fa 08) [http://www.sun.com] ) LWP::Parallel::UserAgent::init_request: -> (HTTP::Request=HASH(0xe0f6b +4)) [GET h ttp://www.sun.com] LWP::Parallel::UserAgent::init_request: GET http://www.sun.com LWP::UserAgent::_need_proxy: Not proxied LWP::Parallel::UserAgent::on_failure: (http://www.sun.com) LWP::Parallel::UserAgent::_check_bandwith: Failed connection for 'www. +sun.com:80 ' LWP::Parallel::UserAgent::_check_bandwith: (LWP::Parallel::UserAgent:: +Entry=HASH (0xe11624) [http://www.sun.com] ) LWP::Parallel::UserAgent::on_connect: (http://www.sun.com) LWP::Parallel::UserAgent::_connect: (LWP::Parallel::UserAgent::Entry=H +ASH(0xe116 24) [http://www.sun.com] ) LWP::Parallel::UserAgent::init_request: -> (HTTP::Request=HASH(0xe113f +c)) [GET h ttp://www.sun.com] LWP::Parallel::UserAgent::init_request: GET http://www.sun.com LWP::UserAgent::_need_proxy: Not proxied LWP::Parallel::UserAgent::on_failure: (http://www.sun.com) LWP::Parallel::UserAgent::_check_bandwith: Failed connection for 'www. +sun.com:80 ' LWP::Parallel::UserAgent::_make_connections_unordered: Queue for www.s +un.com:80 contains 0 pending connections .... ....
The test-script:
use strict; use LWP::Parallel::UserAgent; #Turns on debug mode _ outputs lot of info.. use LWP::Debug qw(+); $|++; my @sites = qw ( http://www.cnn.com http://www.sun.com http://www.msn.com http://www.sun.com http://www.bbc.co.uk ); my $totalbytes = 0; my $pua = LWP::Parallel::UserAgent->new(); #Build requests foreach (@sites) { my $req = HTTP::Request->new('GET',$_); $pua->register($req, \&Callback); } #Initiate request $pua->wait(); printf "\n\nTotalbytes read:%.2f KB", $totalbytes/1024; sub Callback { my ($data, $response, $protocol) = @_; $totalbytes += length $data; print "\nGot ",length $data," bytes of data from ", $response->bas +e; }
Any ideas?

Thanks.

Replies are listed 'Best First'.
Re: Using LWP::Parallel::UserAgent with perlapp/perl2exe
by tachyon (Chancellor) on Aug 26, 2004 at 13:00 UTC

    Any ideas?

    Sure, besides the get a real OS one. -> Use the source Luke. You can see from the debug output that it tries to connect to all 5 URLs so the forking seems intact but is getting 'Failed connection for' errors in the _check_bandwith() function. In fact you can follow the stack trace from beginning to end. Here is a single failure:

    LWP::Parallel::UserAgent::_check_bandwith: (LWP::Parallel::UserAgent:: +Entry=HASH(0xe0f768) [http://www.cnn.com] ) LWP::Parallel::UserAgent::on_connect: (http://www.cnn.com) LWP::Parallel::UserAgent::_connect: (LWP::Parallel::UserAgent::Entry=H +ASH(0xe0f768) [http://www.cnn.com] ) LWP::Parallel::UserAgent::init_request: -> (HTTP::Request=HASH(0xa0c23 +c)) [GET http://www.cnn.com] LWP::Parallel::UserAgent::init_request: GET http://www.cnn.com LWP::UserAgent::_need_proxy: Not proxied LWP::Parallel::UserAgent::on_failure: (http://www.cnn.com) LWP::Parallel::UserAgent::_check_bandwith: Failed connection for 'www. +cnn.com:80 '

    If you follow through the code you will be able to see that..... the error comes from init_request, which returns a (possibly useful error message) which is them simply ignored due to the calling syntax.

      Thanks tachyon! (or should i say obi :) I started out in the source code where you pinpointed and followed the trace through some other moduels and this brought me to the conclusion that perlapp didn't include the LWP::Parallel::Protocol::http-module when "compiling"..so by just adding:

      use LWP::Parallel::Protocol::http;

      everything worked fine.