3

I have a template with a static image. Each second call of this page the image doesn't display and I get next error in the console:

Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[24/Oct/2010 11:25:36] "GET /index/ HTTP/1.1" 200 20058
[24/Oct/2010 11:25:36] "GET /images/logo.png HTTP/1.1" 500 65126
[24/Oct/2010 11:25:37] "GET /index/ HTTP/1.1" 200 20058
[24/Oct/2010 11:25:37] "GET /images/logo.png HTTP/1.1" 200 6439
[24/Oct/2010 11:25:39] "GET /index/ HTTP/1.1" 200 20058
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 281, in run self.finish_response()
  File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 321, in   finish_response self.write(data)
  File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 417, in write
self._write(data)
  File "C:\Python27\lib\socket.py", line 322, in write
self.flush()
  File "C:\Python27\lib\socket.py", line 301, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 10053] An established connection was aborted by the software in your host machine
Traceback (most recent call last):
  File "C:\Python27\lib\SocketServer.py", line 284, in _handle_request_noblock
self.process_request(request, client_address)
  File "C:\Python27\lib\SocketServer.py", line 310, in process_request
self.finish_request(request, client_address)
  File "C:\Python27\lib\SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
  File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 562, in __init__
  BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
 File "C:\Python27\lib\SocketServer.py", line 641, in __init__
self.finish()
  File "C:\Python27\lib\SocketServer.py", line 694, in finish
self.wfile.flush()
  File "C:\Python27\lib\socket.py", line 301, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 10053] An established connection was aborted by the software in your host machine
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 38314)
----------------------------------------

How can I fix it?

Seitaridis
  • 4,459
  • 9
  • 53
  • 85
ceth
  • 44,198
  • 62
  • 180
  • 289

3 Answers3

2

Maybe you have another application that uses 8000 port number. Did you tried using another port number?

Seitaridis
  • 4,459
  • 9
  • 53
  • 85
  • I have changed the port number but have the same problem. – ceth Oct 24 '10 at 09:36
  • Don't know if this will help you solve your problem, but check this link: http://code.google.com/p/googleappengine/issues/detail?id=462 – Seitaridis Oct 24 '10 at 10:33
  • Do you use another server, for example Apache server? If so then do you encounter the same issue? – Seitaridis Oct 24 '10 at 10:36
  • No, I don't use another server. – ceth Oct 24 '10 at 10:45
  • What Django version do you use? – Seitaridis Oct 24 '10 at 10:51
  • In the link I've sent you says something about another Ajax process. Do you use Ajax in your application? It will be helpful if I can see the template file and where you handle the URL request. Also paste the contents of the urls.py – Seitaridis Oct 24 '10 at 11:39
  • 1
    This is my answer on a similar problem: http://stackoverflow.com/questions/3931151/django-how-add-static-files/3931297#3931297 . – Seitaridis Oct 24 '10 at 12:19
  • Thanks. I moved the absolute path to settings.py and set settings.MEDIA_ROOT to urls.py, but the error remain. – ceth Oct 24 '10 at 12:41
  • How it looks now your urls.py and template? – Seitaridis Oct 24 '10 at 12:44
  • Hmmm... may be I have more information. I am just calling this url 'http://127.0.0.1:8004/images/logo.png' and each second call I have this error message in browser: http://pastebin.com/NG7m8QjZ. Can it help? – ceth Oct 24 '10 at 12:53
  • Another thing. I've just noticed that ('^import/$', importContent), should be with an 'r'. Change ('^index/$', index), to (r'^index/$', index), – Seitaridis Oct 24 '10 at 12:57
  • I fixed it, but the problem remains. I looked at site-packages/django/views/static.py. There is a function in this file http://pastebin.com/WxT2qqZu. When header is None -> the image display in the browser. When the header is not None -> I get error. If I add my line (commented in the code) the problems disappeared, but I understand that is not good way. – ceth Oct 24 '10 at 13:03
  • Before making some modifications to the code you received a [Errno 10053]. In the paste response I saw that there is a OverflowError. Do you still have the first error? – Seitaridis Oct 24 '10 at 13:08
  • [Errno 10053] was in console and I didn't have that error after I have changed urls.py. – ceth Oct 24 '10 at 13:16
  • But I'm thinking at what could cause the OverflowError error. – Seitaridis Oct 24 '10 at 13:31
  • Are you working with eclipse? I've changed Text file encoding to UTF-8 and now I don't get this error anymore... – zigomir Dec 20 '10 at 14:08
1

Check if you are providing a request context from your view. In my case this happened when {{STATIC_URL}} was missing, and it was missing because I forgot to add a request context to the render_to_response() function.

Erik Oosterwaal
  • 4,272
  • 3
  • 44
  • 64
0

This is a Chrome-related issue. To stop getting those errors you have to uncheck "Predict network actions to improve page load performance" in Chrome settings.

marpetr
  • 183
  • 6