Note - In this page it is assumed that you run the Apache HTTP server.
1- Setup
Whenever a program check is met, Apache HTTP server jobs bump out,
and all the diagnostics are then in their joblogs.
So, first of all, HTTP server jobs must have a readable joblog. This is how you do it:
- chgjobd qhttpsvr/qzhbhttp log(4 00 *seclvl)
inqmsgrpy(*dft)
- endtcpsvr *http
- strtcpsvr *http
Second, you must change the "script time-out" value
in your http directives, by specifying a time value
high enough to let you complete your debugs
without having the server job terminating
because of an excessive wait time on the server response.
- edtf '/www/http_instance_name/conf/httpd.conf'
- add or change the following directive
TimeOut nn
by specifying af least 1800 (30 minutes) for nn .
- endtcpsvr *http
- strtcpsvr *http
If the HTTP server job does not bump out and you want to debug a CGI program of yours,
you must first find out which HTTP job is going to serve your request.
To find out the HTTP job servicing your request
- wrkactjob sbs(qhttpsvr) job(instance_name)
- press F10 several times to reset counts
- run any HTTP request that would not fail
- press F5 to refresh the counts
- the HTTP job servicing your request is the CGI one displaying some CPU time.
2- HTTP instance configuration
- If your browser displays
error 404,
that may just mean that your HTTP directives are not working
- If you have installed library cgidev2,
clear the cash of your web browser and
try to run the following:
http://.../cgidev2o/hello.htm
(replace ... with the TCP address of your AS/400)
- If you get no response, but an Error 400 message,
it may mean that your HTTP server is not serving your request.
Some of the causes:
- Your HTTP server is not active;
you can check it by entering command
wrkactjob sbs(qhttpsvr)
- Your HTTP server is active, but some other
active HTTP server is locking port 80
for its own exclusive use.
This happens for instance when you also run
DOMINO.
You may then try to change the port of your
HTTP configuration in the following way:
- Enter command
edtf '/www/http_instance_name/conf/httpd.conf'
to edit the HTTP server instance directives
- Look for a Listen directive.
- Change the port number on the
Listen directive.
For instance, instead of port 80,
assign port 7777.
- Re-start the HTTP server instance
- Re-try the URL by entering
http://...:7777/cgidev2o/hello.htm
- If you get Error 500 in running
http://.../cgidev2o/hello.htm
do the following:
- make sure that library CGIDEV2 and program CGIDEV2/HELLO1
are authorized to the *public for *use
- make sure that the configuration directives of
your HTTP server
contain the directives needed to run CGIDEV2,
and that this HTTP server was re-started after installing
such directives (to install CGIDEV2 HTTP directives, run command
command CGIDEV2/HTTPCFG)
- make sure you installed the last available PTF Cumulative
for product 57xxDG1 (IBM HTTP Server for iSeries)
3- Error 500 trivial cases
Error 500 is raised in four cases:
- The mandatory HTTP header is missing.
The HTTP headers are statements at the beginning of the output generated from a CGI for the browser.
The fist mandatory HTTP header must be:
Content type: ...
In absense of such HTTP header, you get ERROR 500 from Apache.
Another common HTTP header is
Expires: 0
- The mandatory HTTP headers separator is missing.
The HTTP headers must end with a sequence of two Carriage-Return-Line-Feed (CRLF).
This is implemented by adding an empty line after the last HTTP header.
In absense of such a separator, you get ERROR 500 from Apache.
- The output buffer is not sent to the browser
The CGI program returns without sending the output buffer via the statement
callp wrtsection('*fini')
- The CGI program faces a program exception and is terminated.
This is the topic discussed hereafter.
|
4- Error 500 non trivial case
If the HTTP instance job servicing your CGI request was terminated due to a program exception,
you should first look at its joblog (output queue QEZJOBLOG).
In many cases, error messages provide enough information to enable program correction.
For more complex cases, you need to debug your CGI program.
To perform debug, you must have compiled your ILE modules
with the option
DBGVIEW(*SOURCE)
or
DBGVIEW(*LIST)
If you have done so,
|
- strsrvjob .....
the http server job which you expect to process your next CGI request
- strdbg your_CGI_program updprod(*yes)
Note- To be quicker, you may use command EDBG (Enhanced Debug) available with CGIDEV2
(use F4 to prompt parameters).
- Some basics, when the source of the initial module
is displayed
- on the command line,
F string
to find a string
- F16 to find next
- move a cursor to a source line and press F6
to add a breakpoint
- Rerun your CGI program.
Hopefully it will stop at some breakpoint of yours,
you may tell from your debug session
- More hints on debug
- position the cursor on a variable
and press F11 to display its value
- you can do the same on the command line by entering
eval variable_name
- if you want to display the value of a variable in hexadecimal format, on the command line enter
eval variable_name:x
- to change the value of a variable, on the command line enter
- eval variable_name = 'value'
if it is a character variable
- eval variable_name = value
if it is a numeric variable
- to execute one step of coding, press F10
- to resume execution till the next breakpoint, press F12
- if your module calls another module, and you want
to debug this latter one
- add a breakpoint on the call statement
- when execution stops on this statement,
press F22 to display and add breakpoints
to this latter module
By sure you will become the most proficient debugger
in your neighbourhood!
|