Hi, I have a queue server script written using POE::Session. The queue server dies with a weird return value and this behavior is not predictable.

The expected output of the url sent to the queue is always '1'. But sometimes the following Http::Response is received (unexpected output)

Wrong response:
HTTP/1.1 200 OK
Cache-Control: private
Connection: close
Date: Fri, 18 Jun 2010 11:19:33 GMT
Content-Encoding: gzip
Content-Type: text/plain;charset=utf-8
P3P: policyref="/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"

2????


===================================
Successful Http::Response:

Cache-Control: private
Connection: close
Date: Mon, 21 Jun 2010 11:20:12 GMT
Content-Encoding: gzip
Content-Type: text/plain;charset=utf-8
P3P: policyref="/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"

1


===================================

The code Snippet: (where queue waits for the response)
POE::Session->create ( inline_states => { _start => sub { my ( $kernel, $heap ) = @_[ KERNEL, HEAP ]; # Post a request to the HTTP user agent component. When the # component has an answer (positive or negative), it will # send back a "got_response" event with an HTTP::Response # object. $heap->{www_time_start} = [gettimeofday]; $kernel->post( "BY-ua" => request => got_response => GET $url ); $self->queue_stats("enqueue", $url); }, # A response has arrived. Display it. got_response => sub { my ( $heap, $request_packet, $response_packet ) = @_[ HEAP, ARG0, ARG1 ]; my $http_request = $request_packet->[0]; my $http_response = $response_packet->[0]; my $iv = tv_interval ($heap->{www_time_start}); my $url_iv = sprintf "%s=%.2f", substr($http_request->url(), -10), $iv; DEBUG "Response time: $iv"; # Make the response presentable, and display it. DEBUG "Received result for ", $http_request->url(), ": ", $http_response->as_string(); }, );
Any pointers on how to resolve this issue ? Thanks

In reply to Queue dies with unexpected output by vmraj

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.