J'ai une application Web Django fonctionnant sous Apache avec mod_wsgi sur mon serveur dédié Centos 5.5.
Cependant, parfois (six ou sept fois par jour), il commence à donner une erreur 500 pour certaines pages aléatoires. Mais si je rafraîchis la page deux ou trois fois, la page redevient normale. Mais une fois qu'il commence à donner l'erreur 500, toutes les autres pages de mon site Web donnent cette erreur.
Après avoir redémarré l'apache, il redevient normal pendant 5 ou 6 heures mais il ne cesse de donner cette erreur.
Je colle le journal d'erreur complet ci-dessous mais en effet, il indique que DjangoUnicodeDecodeError: 'utf8' codec can't decode byte 0xdd in position 330: invalid continuation byte.
Quelle peut être la cause de ce type d'erreur et comment puis-je la détecter ? Je peux fournir toute information supplémentaire dès que possible.
PS : J'ai la même configuration sur mon PC local (Apache-mod_wsgi). with Win7
et je n'ai jamais eu cette erreur.
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30] mod_wsgi (pid=30331): Exception occurred processing WSGI script '/var/www/html/MY_SITE/django.wsgi'., referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30] Traceback (most recent call last):, referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30] File "/opt/python2.7.1/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 273, in __call__, referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30] response = self.get_response(request), referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30] File "/opt/python2.7.1/lib/python2.7/site-packages/django/core/handlers/base.py", line 169, in get_response, referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30] response = self.handle_uncaught_exception(request, resolver, sys.exc_info()), referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30] File "/opt/python2.7.1/lib/python2.7/site-packages/django/core/handlers/base.py", line 203, in handle_uncaught_exception, referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30] return debug.technical_500_response(request, *exc_info), referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30] File "/opt/python2.7.1/lib/python2.7/site-packages/django/views/debug.py", line 59, in technical_500_response, referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30] html = reporter.get_traceback_html(), referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30] File "/opt/python2.7.1/lib/python2.7/site-packages/django/views/debug.py", line 117, in get_traceback_html, referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30] frame['vars'] = [(k, force_escape(pprint(v))) for k, v in frame['vars']], referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30] File "/opt/python2.7.1/lib/python2.7/site-packages/django/template/defaultfilters.py", line 34, in _dec, referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30] args[0] = force_unicode(args[0]), referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30] File "/opt/python2.7.1/lib/python2.7/site-packages/django/utils/encoding.py", line 93, in force_unicode, referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30] raise DjangoUnicodeDecodeError(s, *e.args), referer: http://www.MY_SITE.com/
[Wed Sep 28 12:03:53 2011] [error] [client 46.104.250.30] DjangoUnicodeDecodeError: 'utf8' codec can't decode byte 0xdd in position 330: invalid continuation byte. You passed in "<WSGIRequest\\nGET:<QueryDict: {}>,\\nPOST:<QueryDict: {}>,\\nCOOKIES:{},\\nMETA:{'CSRF_COOKIE': '041ed0a93c4b355d4861a0662d49fcb4',\\n 'DOCUMENT_ROOT': '/var/www/html/MY_SITE',\\n 'GATEWAY_INTERFACE': 'CGI/1.1',\\n 'HTTP_ACCEPT': 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',\\n 'HTTP_ACCEPT_ENCOD\\xddNG': 'gzip, deflate',\\n 'HTTP_ACCEPT_LANGUAGE': 'en-us',\\n 'HTTP_CACHE_CONTROL': 'max-age=0',\\n 'HTTP_CONNECT\\xddON': 'keep-alive',\\n 'HTTP_COOK\\xddE': 'csrftoken=10bc570d4ef77b17ce580106dafa9fb6; sessionid=60fb98634573194f7f5e18ef6014f59b',\\n 'HTTP_HOST': 'www.MY_SITE.com',\\n 'HTTP_REFERER': 'http://www.MY_SITE.com/',\\n 'HTTP_USER_AGENT': 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B367 Safari/531.21.10',\\n 'PATH_INFO': u'/main/faq/',\\n 'PATH_TRANSLATED': '/var/www/html/MY_SITE/django.wsgi/main/faq/',\\n 'QUERY_STRING': '',\\n 'REMOTE_ADDR': '46.104.250.30',\\n 'REMOTE_PORT': '49643',\\n 'REQUEST_METHOD': 'GET',\\n 'REQUEST_URI': '/main/faq/',\\n 'SCRIPT_FILENAME': '/var/www/html/MY_SITE/django.wsgi',\\n 'SCRIPT_NAME': u'',\\n 'SERVER_ADDR': '93.94.251.82',\\n 'SERVER_ADMIN': 'bilgi@MY_SITE.com',\\n 'SERVER_NAME': 'www.MY_SITE.com',\\n 'SERVER_PORT': '80',\\n 'SERVER_PROTOCOL': 'HTTP/1.1',\\n 'SERVER_SIGNATURE': '<address>Apache/2.2.3 (CentOS) Server at www.MY_SITE.com Port 80</address>\\\\n',\\n 'SERVER_SOFTWARE': 'Apache/2.2.3 (CentOS)',\\n 'mod_wsgi.application_group': 'MY_SITE.com|',\\n 'mod_wsgi.callable_object': 'application',\\n 'mod_wsgi.handler_script': '',\\n 'mod_wsgi.input_chunked': '0',\\n 'mod_wsgi.listener_host': '',\\n 'mod_wsgi.listener_port': '80',\\n 'mod_wsgi.process_group': '',\\n 'mod_wsgi.request_handler': 'wsgi-script',\\n 'mod_wsgi.script_reloading': '1',\\n 'mod_wsgi.version': (3, 3),\\n 'wsgi.errors': <mod_wsgi.Log object at 0x2b7d75ddbfb0>,\\n 'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter object at 0x2b7d75f12a80>,\\n 'wsgi.input': <mod_wsgi.Input object at 0x2b7d75fa0a30>,\\n 'wsgi.multiprocess': True,\\n 'wsgi.multithread': False,\\n 'wsgi.run_once': False,\\n 'wsgi.url_scheme': 'http',\\n 'wsgi.version': (1, 1)}>" (<type 'str'>), referer: http://www.MY_SITE.com/
Le site web fonctionne sans problème à la fois avec Apache et le serveur de développement intégré de Django sur mon ordinateur local (Win7, Apache, mod_wsgi).