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

I have a perl script that implements a web service using Frontier::RPC2 and Frontier::Responder . I have written a test script that invokes the various methods and get results. 32 of the tests succeed. However, I am finding that I am receiving the following when I invoke what seems to be 2 pretty simple methods (this message, of course, is only from one of the two tests - the other test generates a quite similar error):
Uncaught exception from user code: 500 Too many header lines (limit is 128) Frontier::Client::call('Frontier::Client=HASH(0x13b608)', 'Get +AllByDept', 27) called at Misc/testuiv2.pl line 119
The line 119 in the test script is:
$aresults = $server->call('GetAllByDept', $dept_no);
where $dept_no is 27. The method is pretty simple and works like the other methods already tested. When I run the sql statement used in the method directly against the database, it works without a problem. Here's the code in the method.
sub GetAllByDept{ my (@next_row); my @retval; #this will be array of arrays my $rc; my($SearchDept) = @_ or do { ERROR( "GetAllByDept: no argument provided" ); return \@retval; }; INFO( "GetAllByDept: $SearchDept passed" ); if ($SearchDept !~ /^\d+$/) { ERROR( "GetAllByDept: argument provided not a number" ); return \@retval; } #query db to find information my $dbconn = DBI->connect("DBI:Oracle:$DBHOST",$DBUSER,$DBPASS) or d +o { ERROR( "GetAllByDept: ORACLE connect failed - $DBI::errstr" ); + return \@retval; }; my $query = $dbconn->prepare( "Select * from $Schema.CSI_HR_V2 where DEPT_NO = ?") o +r do { ERROR( "GetAllByDept: ORACLE prepare failed - $DBI::errstr" ); $dbconn->disconnect(); return \@retval; }; DEBUG( "GetAllByDept: query = $query" ); $rc = $query->execute($SearchDept) or do { ERROR( "GetAllByDept: ORACLE execute failed for $SearchDept - +$DBI::errs tr" ); $query->finish; $dbconn->disconnect(); return \@retval; #problem return empty array }; my $count = 0; @next_row= $query->fetchrow_array(); while (@next_row) #get rows and add to return array of hashes { #get staff information $count++; push(@retval,{Alt_Emp_No => $next_row[0], Job_Class => $next_row[1 +], Title => $next_row[2],Dept_Code => $next_row[3], Dept_No => $next_row[4], Last_Name => $next_row[5],First_Name => $next_row[6], Middle_Name => $next_row[7], Supervisor_Emp_No => $next_row[8], Status => $next_row +[9], Suffix_Name => $next_row[10], Extension => $next_row +[11], Room_No => $next_row[12], Email => $next_row[13], Login => $next_row[14], Login_History => $next_row[1 +5], Contractor => $next_row[16], Create_Date => $next_row[17], Mod_Date => $next_row[18 +] }); @next_row= $query->fetchrow_array(); } INFO( "GetAllByDept: $count records found for $SearchDept"); $query->finish; $dbconn->disconnect(); return \@retval; }
The web service methods all are using DBI and the CGI modules as well. The parameters for the DBI connection are set on entry to the program, and are being used by all the methods, so there is no difference there. The query itself only returns 27 rows, so I don't understand the reference to 128 headers. Has anyone any suggestions on what I might be able to do to fix it? Thank you very much.

Replies are listed 'Best First'.
Re: Help sought determining why Frontier::Client reporting too many header lines
by sierpinski (Chaplain) on Jun 28, 2010 at 17:53 UTC
    I have to ask the obvious, do you have too many header lines? A quick google of your error message shows one case where someone (well an application) was trying to set WAY too many cookies in the header portion of the file.

    What does the header part of your code look like? It's obvious that the problem lies there somewhere, whether it be cookies or otherwise. Please post full code, or at least the part that comes before what you've already posted.
      I haven't been able to figure out how to print out the headers to see whether there are too many. There really isn't much before the method:
      BEGIN { use Log::Log4perl qw(:easy); Log::Log4perl->easy_init( { file => ">> /tmp/uiv2_logfile.txt", level => $INFO, }, ); $SIG{__DIE__} = sub { if($^S) { # We're in an eval {} and don't want to log # this message but catch it later return; } $Log::Log4perl::caller_depth++; LOGDIE @_; }; } use strict; use warnings; use diagnostics; use CGI; use CGI::Carp 'fatalsToBrowser'; use Frontier::RPC2; use Frontier::Responder; use DBI; $ENV{ORACLE_HOME} = '/vol/ora_client/product/10.2.0.2'; my $Schema = "lv"; my $conn_data="/path/to/connection_information"; open (CONNECTION_DATA, $conn_data) or die "Failed to open connection data file\n"; my $DBHOST = <CONNECTION_DATA>; my $DBUSER = <CONNECTION_DATA>; my $DBPASS = <CONNECTION_DATA>; close (CONNECTION_DATA); chomp ($DBHOST); chomp ($DBUSER); chomp ($DBPASS); my $res = Frontier::Responder->new( methods => { Get_Login => \&Get_Login, Get_Last_Name => \&Get_Last_Name, Get_First_Name => \&Get_First_Name, Get_Dept_No => \&Get_Dept_No, Get_AltEmpNo => \&Get_AltEmpNo, Get_Supervisor_Emp_No => \&Get_Supervisor_Emp_No, Get_Job_Class => \&Get_Job_Class, GetAllByLastName => \&GetAllByLastName, GetAllByFirstName => \&GetAllByFirstName, GetAllByFirstOrLastName => \&GetAllByFirstOrLastName +, GetAllByLogin => \&GetAllByLogin, GetAllByDept => \&GetAllByDept, GetAllByEmpNo => \&GetAllByEmpNo, GetAllByDeptExtRoom => \&GetAllByDeptExtRoom, GetAllBySupervisor => \&GetAllBySupervisor, GetUnixContractorInfo => \&GetUnixContractorInfo, GetManagerList => \&GetManagerList, GetPeopleReportingTo => \&GetPeopleReportingTo, Get_LoginByEmpNo => \&Get_LoginByEmpNo } ); print $res->answer;
      : followed by each of the methods. : Any setting of headers is being done inside Frontier. And, as I said, I've tests for each of the methods, and most are working fine. For that matter, if I pass this method a different department number, it works okay. I have 2 departments in my test data - one department has 2 people in it, and the other has 27 people in it. In the live system, there's going to be departments with a couple hundred people in it! I don't see anything obvious in the method that should impact the headers. But I don't know what code is generating the headers, so I can't tell if there's something weird in the CGI environment that's influcing the code in this one case.
        To test to see if it is the cookies issue (I'm sure there can be multiple causes for this error -- but cookies is the first one I've found documented) you can clear cache on your browser, and turn on 'ask me every time' for cookies (and delete the existing cookies) and see how many times you get prompted for cookies. It's very possible that each user has multiple cookies (or generates multiple headers in general, if cookies aren't the culprit) that are causing the error. (or just browse your cookies afterward to see how many exist for your site after using the dept with 27 people)

        If it's directly related to the number of people in that department, then I'd have to deduce that it's doing something for each of those people. It might be cookies, it might be some other type of header, but that has to be part of the reason.

        Have you tried looking into the module code to see what it's trying to do? I don't have that module handy, but it might spill the beans as to what's going on, and perhaps there is some option to change the behavior to prevent this issue.

        I looked on CPAN and found this bug for one of the Frontier modules. It talks about a 500 error, perhaps it's related to the one you are receiving. It's very possible that it's a bug in the module and nothing in your code can prevent it, which in case you'll either have to get it fixed yourself, or hope the author fixes it. I'd definitely examine the source of the module though to see if you can spot where the issue really is. Unfortunately I can't do that at the moment, but I will try to take a look later on if I can.

        I hope that was helpful.