Django ConnectionAbortedError: [WinError 10053]一系列错误

Exception happened during processing of request from ('127.0.0.1', 61328)
Traceback (most recent call last):
  File "D:\Anaconda\lib\wsgiref\handlers.py", line 138, in run
    self.finish_response()
  File "D:\Anaconda\lib\wsgiref\handlers.py", line 180, in finish_response
    self.write(data)
  File "D:\Anaconda\lib\wsgiref\handlers.py", line 274, in write
    self.send_headers()
  File "D:\Anaconda\lib\wsgiref\handlers.py", line 332, in send_headers
    self.send_preamble()
  File "D:\Anaconda\lib\wsgiref\handlers.py", line 255, in send_preamble
    ('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
  File "D:\Anaconda\lib\wsgiref\handlers.py", line 453, in _write
    result = self.stdout.write(data)
  File "D:\Anaconda\lib\socketserver.py", line 775, in write
    self._sock.sendall(b)
ConnectionAbortedError: [WinError 10053] 你的主机中的软件中止了一个已建立的连接。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Anaconda\lib\wsgiref\handlers.py", line 141, in run
    self.handle_error()
  File "D:\Anaconda\lib\site-packages\django\core\servers\basehttp.py", line 86, in handle_error
    super().handle_error()
  File "D:\Anaconda\lib\wsgiref\handlers.py", line 368, in handle_error
    self.finish_response()
  File "D:\Anaconda\lib\wsgiref\handlers.py", line 180, in finish_response
    self.write(data)
  File "D:\Anaconda\lib\wsgiref\handlers.py", line 274, in write
    self.send_headers()
  File "D:\Anaconda\lib\wsgiref\handlers.py", line 331, in send_headers
    if not self.origin_server or self.client_is_modern():
  File "D:\Anaconda\lib\wsgiref\handlers.py", line 344, in client_is_modern
    return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Anaconda\lib\socketserver.py", line 639, in process_request_thread
    self.finish_request(request, client_address)
  File "D:\Anaconda\lib\socketserver.py", line 361, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "D:\Anaconda\lib\socketserver.py", line 696, in __init__
    self.handle()
  File "D:\Anaconda\lib\site-packages\django\core\servers\basehttp.py", line 154, in handle
    handler.run(self.server.get_app())
  File "D:\Anaconda\lib\wsgiref\handlers.py", line 144, in run
    self.close()
  File "D:\Anaconda\lib\wsgiref\simple_server.py", line 35, in close
    self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'

报错原因:

因为ajax默认是异步提交,可是有时候我们会发现,本来要求请求马上出现,是异步会导致后面突然再执行,可这样就出问题了。 
解决方案:

解决方式一:

在ajax进行异步提交时,将async 改为 false 即可

$.ajax({  
         type : "post",  
         url : "**************",  
         data : data,  
         async : false,  
         success : function(data){  
            alert(data)  
         }  
     });

解决方式二:

报错一:self._sock.sendall(b) ConnectionAbortedError: [WinError 10053] 您的主机中的软件中止了一个已建立的连接。

解决方法:找到D:\Anaconda\lib\socketserver.py文件775行,修改SocketWriter类的write方法,具体如下:

def write(self, b):
        try:
            self._sock.sendall(b)
        except Exception as e:
          self._sock.close()
        with memoryview(b) as view:
            return view.nbytes

报错二:return self.environ[‘SERVER_PROTOCOL’].upper() != 'HTTP/0.9 TypeError: ‘NoneType’ object is not subscriptable

解决方法:找到D:\Anaconda\lib\wsgiref\handlers.py文件344行,修改client_is_modern函数,具体如下:

def client_is_modern(self):
        """True if client can accept status and headers"""
        try:
            cmp = self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
        except Exception as e:
            cmp = False
        return cmp

报错三:self.status.split(’ ',1)[0], self.bytes_sent AttributeError: ‘NoneType’ object has no attribute 'split

解决方法:打开python\lib\wsgiref\simple_server.py文件28行,修改ServerHandler类,具体如下:

class ServerHandler(SimpleHandler):

    server_software = software_version

    def close(self):
        try:
            self.request_handler.log_request(
                self.status.split(' ',1)[0], self.bytes_sent
            )
            SimpleHandler.close(self)
        except Exception as e:
            SimpleHandler.close(self)

报错四:“GET /favicon.ico HTTP/1.1” 404 3163

解决方法:在static文件下的img文件添加一个favicon.ico图片,然后在页面头部加入

<link rel="icon" href="/static/img/favicon.ico" type="image/x-icon"/>

https://blog.csdn.net/u010006381/article/details/83339321

  • 3
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值