I have a web service running through django/apache/mod_wsgi that I am trying to debug -- it takes a long time to run server-side, but with certain parameters it just times out. I've tried doing a straight up
wget on the URI, and using
urllib2. I get the following error from
Read error (Connection timed out) in headers
urllib2 returns nothing at all -- it seems to be erroring silently. I've tried increasing the
Timeout directive in my apache config, but that doesn't seem to help. The service runs fine with different parameters. How should I debug this? Where is the timeout coming from if not apache?
Chances are the problem is in you services code. Make sure your services code completes executing and returns to apache before trying to debug apache.
I would suggest that you trace through the services code adding output statements. Be sure to add a ouput statement just before your code returns to mod_wsgi (the last line of the function that mod_wsgi calls.) Chances are what you will see is the code hanging in a particular spot. That is all the debug statements prior to that spot in the code will appear, none of the output statements after that spot will appear.
If you don't want to add debug statement try using a debugger to step through the code.
Another option is to use the django development server and see if the timeout occurs when running without apache. However, since the development server is single threaded your code won't hang if the problem your dealing with is a concurrency related bug.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki