微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Django: ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine

 ========================================

Traceback (most recent call last):
  File "D:\Program Files\python_3_6_4\lib\wsgiref\handlers.py", line 138, in run
    self.finish_response()
  File "D:\Program Files\python_3_6_4\lib\wsgiref\handlers.py", line 180, in finish_response
    self.write(data)
  File "D:\Program Files\python_3_6_4\lib\wsgiref\handlers.py", line 274, in write
    self.send_headers()
  File "D:\Program Files\python_3_6_4\lib\wsgiref\handlers.py", line 332, in send_headers
    self.send_preamble()
  File "D:\Program Files\python_3_6_4\lib\wsgiref\handlers.py", line 255, in send_preamble
    ('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
  File "D:\Program Files\python_3_6_4\lib\wsgiref\handlers.py", line 453, in _write
    result = self.stdout.write(data)
  File "D:\Program Files\python_3_6_4\lib\socketserver.py", line 775, in write
    self._sock.sendall(b)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
========================================

 

 

You have set up a query and a db that are using the same language. However while the DB used a code page with 850 possible characters, your session had 1252 possible characters. When the two tries to communicate there are symbols that cannot match up between the query and the DB.

cmd.exe /c chcp 1252 -> sets the query language to 1252 possible characters == db(1252 possible characters), which resolves the issue.

 

Please try setting code page before launching Django.

 

运行以下命令即可:

cmd.exe /c chcp 1252

 

 

=================================================

 

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

 

=================================================

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

解决方法(可行)

找到python/Lib/socketserver.py文件修改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

=================================================

 

 

REF:

https://stackoverflow.com/questions/54465300/django-connectionabortederror-winerror-10053-an-established-connection-was-a

https://blog.csdn.net/qq_38003892/article/details/79902565

https://blog.csdn.net/weixin_43917239/article/details/93967462

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐