Django / Apache / mod_wsgi - WEB Application Hangs - Fails to Launch - django

My Django WEB Application fails to launch all of a sudden and out of the blues.
It was working fine until yesterday in production.
I am not able to figure out where the problem is. It could apache or mod_wsgi or windows but at the moment I have no clue.
I have tried to reinstall all the python libraries/prerequisites etc. but the problem persists nevertheless.
I am serving the WEBApp at Apache Port 8999 and When I access the WEB App, the browser fails to show any error. It just keeps trying to open the page and in the status bar I just see the Waiting for message.
If I see the netstat results then I see the following
C:\Documents and Settings\admintemp>netstat -an | find "8999" TCP
0.0.0.0:8999 0.0.0.0:0 LISTENING TCP 172.18.148.156:8999 10.107.226.88:1826 ESTABLISHED
This connection remains established forever and nothing happens. Internet Browser just seems to try to keep opening the Web App and it appears as if it is waiting forever.
The only thing i see in Apache logs is this
[Fri Jun 21 18:34:32 2013] [warn] mod_wsgi: Compiled for Python/2.7.
[Fri Jun 21 18:34:32 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Fri Jun 21 18:34:32 2013] [notice] Apache/2.2.22 (Win32) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
[Fri Jun 21 18:34:32 2013] [notice] Server built: Jan 28 2012 11:16:39
[Fri Jun 21 18:34:32 2013] [notice] Parent: Created child process 3876
[Fri Jun 21 18:34:32 2013] [warn] mod_wsgi: Compiled for Python/2.7.
[Fri Jun 21 18:34:32 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Fri Jun 21 18:34:32 2013] [notice] Child 3876: Child process is running
[Fri Jun 21 18:34:32 2013] [notice] Child 3876: Acquired the start mutex.
[Fri Jun 21 18:34:32 2013] [notice] Child 3876: Starting 64 worker threads.
[Fri Jun 21 18:34:32 2013] [notice] Child 3876: Starting thread to listen on port 8999.
[Fri Jun 21 18:34:43 2013] [error] C:/Program Files/App_Logic/logic_apps/logic_apps\\..\\logic_apps
I also noticed in the Windows Event Viewer logs (Application Logs) the following message but I am not sure how (and if) this could be related to my problem at hand. This message seems to shows up once for everytime i access the Web App.
Application popup: Microsoft Visual C++ Runtime Library : Runtime
Error!
Program: C:\Progr...
R6034 An application has made an attempt to load the C runtime library
incorrectly. Please contact the application's support team for more
information.
Exact screenshot of above error message is at http://imgur.com/hijiKv8
Please note that as part of my analysis I have tried
Accesing the apache page at http://127.0.0.1:8999 does show me the It Works ! message
Running the WEB App using the Django Development server and it launches fine.
Changing the wsgi.py file and when I introduce errors in the file deliberately, accessing the web app does complain with the relevant.
The application is installed on Windows Server 2003 SP1 and there are no automatic updates schedules on this machine so I am not suspecting that a update would have caused this problem. I also saw the Windows Update log and there was nothing installed recently.
The application is based on following Python Libraries as prerequisites
httpd-2.2.22-win32-x86-openssl-0.9.8t.msi
python-2.7.3
Django-1.4.3
psycopg2-2.4.6.win32-py2.7-pg9.2.2-release
cx_Oracle-5.1.2-10g.win32-py2.7
PIL-1.1.7.win32-py2.7
python-ldap-2.4.10.win32-py2.7
south-0.7.6
xlrd-0.9.0
xlwt-0.7.5
mod_wsgi.so
I have tried with the WSGIApplicationGroup %{GLOBAL} directive and setting the log level to debug and info but the resulting logs don't give any additional information.
I have posted apache debug level log at http://dpaste.com/1268653/
I have posted apache info level log at http://dpaste.com/1268660/
Both these logs were taken after a fresh restart of apache and then the application hanging and until I stopped apache and copied the logs.
I also tried running the Hello World Application as documented at https://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines and it worked fine.
I still remain clueless. Appreciate if you could guide me what else I could do to get more details of the issue.
Appreciate if someone could guide me with respect to what more I can do to solve this problem or get more information to get to the root of this.

I was able to solve this issue in the end.
The post at Runtime error R6034 in embedded Python application led me to a solution.
Thanks to Graham Dumpleton and others who were helping me offline to get this issue solved.
It was rather cheeky in the end, a conflicting version of msvcr90.dll
I removed the IBM Bit from the path and it works fine now.

Related

Django project crashes server when admin backend is accessed

Problem
I am running apache2 on my local ubuntu server. I set up a Django project using django-admin startproject site and set up my virtual host to use a WSGI Daemon process to run the Django project. This worked and the site is accessible through its IP 192.168.1.3.
When I go to /admin, it allows me to log in and see the initial backend but loads for 5 minutes then goes to a 500 error when I click anything or reload, even when trying to access the non-admin index page. This persists until I run systemctl restart apache2 and completely restart apache or wait ~10-15 minutes until it fixes itself (only to break again immediately if I access /admin pages).
Versions
Django version 4.1.5
mod-wsgi version 4.9.4
My Attempts
If I run the project with python manage.py runserver, I can access it on 192.168.1.3:8000 and fully use the /admin backend, even creating new users, etc. I then thought it was the WSGI Daemon process somehow messing it up, so I followed the linked section of this page: https://pypi.org/project/mod-wsgi#using-mod-wsgi-express-with-django and ran the site with python manage.py runmodwsgi. The site completely works on 192.168.1.3:8000 along with the /admin, and I can create new users etc., which points to it having nothing to do with the WSGI setup (as well as the non-admin pages working fine on the virtual host WSGI).
I have fully deleted and restarted the Django project, as well as setting up new virtual host .conf files with the proper WSGI information, etc.
I read about an /admin loading issue back in Django 3.0, but I am on 4.1 so that is unrelated.
I am at a complete loss at what the issue could be at this point. Why won't my /admin section work on the virtual host??
EDIT:
The issue is actually definitely the WSGI somehow. I am getting this is my apache error log:
[Sun Jan 29 09:27:12.388714 2023] [wsgi:error] [pid 67623:tid 140212873184832] (70007)The timeout specified has expired: [client 192.168.1.10:63055] mod_wsgi (pid=67623): Failed to proxy response from daemon., referer: http://192.168.1.3/admin/
[Sun Jan 29 09:27:14.427470 2023] [wsgi:error] [pid 67624:tid 140211782657600] [client 192.168.1.10:63053] Timeout when reading response headers from daemon process 'Portfolio': /var/www/Portfolio/Portfolio/wsgi.py, referer: http://192.168.1.3/admin/auth/
[Sun Jan 29 09:27:14.949762 2023] [wsgi:error] [pid 67624:tid 140211279357504] [client 192.168.1.10:63056] Timeout when reading response headers from daemon process 'Portfolio': /var/www/Portfolio/Portfolio/wsgi.py, referer: http://192.168.1.3/admin/auth/
[Sun Jan 29 09:27:16.385674 2023] [wsgi:error] [pid 67623:tid 140212856399424] [client 192.168.1.10:63100] Truncated or oversized response headers received from daemon process 'Portfolio': /var/www/Portfolio/Portfolio/wsgi.py
I still do not know what the solution is, though.
https://forum.djangoproject.com/t/django-apache-deployment-not-working-as-intended/15800
I found the solution. Somehow during the whole setup, adding WSGIApplicationGroup %{GLOBAL} to the /etc/apache2/apache2.conf file was never recommended, at least not that I noticed, but it worked and all the admin functionality works on the virtual host through WSGI Daemon.
Hope this can help someone else.

My Wamp is bugging down?

I installed mysql and wamp 2.4 in my server . I made my wamp automatically start upon startup and also disabled wampmysqld so that it will not conflict with mysql.
Then i put my wamp online .
Last month I can smoothly access my server in my LAN network.
But sometimes this week, I cannot access my server's localhost page on my LAN network. I have to open wamp again and and restart all services and its annoying . There are days that wamp will work the whole day and sometimes you need to restart all services again what seems to be the problem and how to solve this?
I open apache logfile and find this error
[Fri Mar 11 13:45:36.654882 2016] [core:notice] [pid 3200:tid 492] AH00094: Command line: 'c:\\wamp\\bin\\apache\\apache2.4.4\\bin\\httpd.exe -d C:/wamp/bin/apache/Apache2.4.4'
[Fri Mar 11 13:45:36.655882 2016] [mpm_winnt:notice] [pid 3200:tid 492] AH00418: Parent: Created child process 3568
[Fri Mar 11 13:45:37.149910 2016] [mpm_winnt:notice] [pid 3568:tid 300] AH00354: Child: Starting 150 worker threads.

Django with mod_wsgi-express and Apache displays Apache test page instead of site home page

I'm trying to setup a Django based website on a CentOS 6.7 Linux PaaS server VM.
I've installed Python 2.7.8 in a virtualenv.
I'm using Apache 2.2.15 (installed using yum), Django 1.7 (installed using pip2.7) and mod_wsgi-express version 4.4.21 (that I compiled from source).
I've followed the instructions at https://pypi.python.org/pypi/mod_wsgi
and am at a point where this command, issued at the Django project root directory, works for me:
(vishwaas_env)$sudo python manage.py runmodwsgi --host=0.0.0.0 --port=80 --user apache --group apache --server-root=/home/syt_admin/projects/vishwaas/www
I'm able to point my browser to the public ip address of the VM and connect to my site. The error_log located in my server-root directory shows normal operation:
[Thu Dec 03 10:48:22 2015] [notice] Apache/2.2.15 (Unix) mod_wsgi/4.4.21 Python/2.7.8 configured -- resuming normal operations
However, since I would like to start this as a background task, I followed Graham's answer to this question:
how can run django on centos using wsgi
I've setup the server configs:
(vishwaas_env)$ python manage.py runmodwsgi --setup-only --host=0.0.0.0 --port=80 --user apache --group apache --server-root=/home/syt_admin/projects/vishwaas/www
and started the apachectl script in the server-root directory
(vishwaas_env)$ sudo apachectl start
But this time, pointing the browser to the same ip address displays the Apache 2 Test page. Also, this time, the error_log that contains messages is the one at
/var/log/httpd/error_log
[Thu Dec 03 10:50:52 2015] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Thu Dec 03 10:50:52 2015] [notice] Digest: generating secret for digest authentication ...
[Thu Dec 03 10:50:52 2015] [notice] Digest: done
[Thu Dec 03 10:50:52 2015] [notice] Apache/2.2.15 (Unix) DAV/2 configured -- resuming normal operations
[Thu Dec 03 10:51:03 2015] [error] [client <ip address>] Directory index forbidden by Options directive: /var/www/html/
What am I missing?
Just realized my mistake.
$sudo apachectl start
was executing the script at /usr/sbin/apachectl
and not the one in my local directory.
$sudo ./apachectl start
invoked the one with the correct configs. I need to figure out what is missing in my path definition.

avahi_entry_group_new() failed: Too many objects

I'm working on making a REST API for my research lab's database. I'm using the Django REST framework and I've gotten everything running smoothly on my local machine. All my code is in its own branch in our Mercurial repo. When I switch branches on our server, the website crashes with:
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator, root#localhost and inform
them of the time the error occurred, and anything you might have done
that may have caused the error.
More information about this error may be available in the server error
log.
The error logs on our server look like this:
[Tue Feb 03 12:55:56 2015] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Tue Feb 03 12:55:56 2015] [notice] Digest: generating secret for digest authentication ...
[Tue Feb 03 12:55:56 2015] [notice] Digest: done
[Tue Feb 03 12:55:56 2015] [notice] Apache/2.2.15 (Unix) DAV/2 PHP/5.3.3 mod_ssl/2.2.15 OpenSSL/1.0.1e-fips mod_wsgi/3.2 Python/2.6.6 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations
[Tue Feb 03 12:56:11 2015] [error] avahi_entry_group_add_service_strlst("Lee on [server name]") failed: Local name collision
(this sort of error repeats many times)
[Tue Feb 03 12:56:13 2015] [error] avahi_entry_group_new() failed: Too many objects
(this error repeats many times.)
I've tried Googling the avahi errors to no avail. Anyone have any insight?
Because of the "too many objects" part of the error, I thought that it might somehow be related to not setting the pagination settings for the API. I only have a couple test objects on my local dev version of the database, but the actual database has tens of thousands. I set up pagination and tried again but it didn't change anything.
Turns out the culprit was not having the djangorestframework package installed for the correct version of Python on the server!? Hopefully this helps someone later down the line.

Running WSF-CPP samples

I'm trying to run the Echo sample that comes with WSO2 WSF-CPP, and I get the following errors:
[Tue Dec 18 14:26:51 2012] [error] dep_engine.c(1008) Axis2
Configuration file name not found [Tue Dec 18 14:26:51 2012] [error]
dep_engine.c(872) axis2.xml is not available in client repo . [Tue
Dec 18 14:26:51 2012] [error] conf_init.c(201) Loading deployment
engine failed for client repository . [Tue Dec 18 14:26:51 2012]
[critical] ServiceClient.cpp(223) Cannot create service client
I follow the installation steps in 1 and I don't have any problem, but I'm thinking that there is something missed.
Thanks in advance,
U.
1[http://wso2.org/library/tutorials/dummys-guide-writing-web-service-clients-wso2-wsf-c#Running_Your_First_Web_Service_Client_with_WSO2_WSF_CPP]
Set the environemnt variable WSFCPP_HOME to your WSO2 CPP installation path.
Seems your path is not set correctly thats why you are seeing this error.
(I can run the samples in linux)