【问题标题】:Django ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machineDjango ConnectionAbortedError: [WinError 10053] 已建立的连接被主机中的软件中止
【发布时间】:2016-08-02 13:12:51
【问题描述】:

我正在使用 django 和 postgresql,每当我尝试保存或删除任何内容时,都会发生此错误 -

Traceback (most recent call last):
File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
Not Found: /favicon.ico
File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble()
File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
[02/Aug/2016 18:30:14] "GET /favicon.ico HTTP/1.1" 404 2044
File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 453, in _write
self.stdout.write(data)
File "c:\program files (x86)\python35-32\Lib\socket.py", line 593, in write
return self._sock.send(b)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
[02/Aug/2016 18:30:14] "GET /api/delete/ HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 1712)
Traceback (most recent call last):
 File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble()
File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 453, in _write
self.stdout.write(data)
File "c:\program files (x86)\python35-32\Lib\socket.py", line 593, in write
return self._sock.send(b)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 141, in run
self.handle_error()
File "C:\Users\sushant\Desktop\projects\drfapi\venv\lib\site-packages\django\core\servers\basehttp.py", line 92, in handle_error
super(ServerHandler, self).handle_error()
File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response()
File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "c:\program files (x86)\python35-32\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 "c:\program files (x86)\python35-32\Lib\socketserver.py", line 628, in process_request_thread
self.finish_request(request, client_address)
File "c:\program files (x86)\python35-32\Lib\socketserver.py", line 357, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\sushant\Desktop\projects\drfapi\venv\lib\site-packages\django\core\servers\basehttp.py", line 99, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "c:\program files (x86)\python35-32\Lib\socketserver.py", line 684, in __init__
self.handle()
File "C:\Users\sushant\Desktop\projects\drfapi\venv\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle
handler.run(self.server.get_app())
File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 144, in run
self.close()
File "c:\program files (x86)\python35-32\Lib\wsgiref\simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
----------------------------------------

每当有数据库保存\删除命令时,就会发生两次,第一次没有错误,第二次抛出此错误,因此保存两次。

我的理解是某些程序正在阻止它(如错误所示),所以我删除了我拥有但没有结论的防病毒软件。

有人知道这是怎么回事吗?

编辑:这是一个 Python 错误,已报告 here

【问题讨论】:

  • 您可能会检查您的 Windows 事件日志 - 看起来有些东西正在破坏您的打开连接,因此它无法正确地将响应发送到浏览器或您正在连接的任何东西。您也可以尝试使用requests 来自动化它,看看您是否可以通过这种方式获得更多信息。
  • 我在事件日志中找不到任何东西

标签: python django postgresql


【解决方案1】:

我已经在 Python 中签入了对此的修复:https://github.com/python/cpython/pull/9713

它将在下一版本的 Python 3.7 及更高版本中提供。

【讨论】:

  • 我正在使用 python 3.7.2 但仍然面临同样的问题。有什么建议吗?
  • 3.7 的下一个版本。您的版本已于 2018 年 12 月 24 日发布。
【解决方案2】:

我正在制作一个 Web 应用程序,但在 Windows 10、python 3.7.6、django 3.0.8 中遇到了同样的问题。我尝试了很多东西,终于找到了解决方法。

我使用了一个表单,该表单调用了一个 js 函数 onsubmit,该函数又发送了一个 REST 调用,该调用被取消,并在命令提示符中出现“[WinError 10053] 已建立的连接被主机中的软件中止”错误。

我在 js 函数中添加了参数 method='post' 并使用了 jQuery.ajax,并在函数中添加了 event.preventDefault() 以及一些成功和失败回调。我不明白为什么,但现在我没有收到错误。

希望这可以帮助任何使用 js 和 HTML 表单的人,直到问题得到根源并得到解决。

Github bug 正在跟踪问题

【讨论】:

    【解决方案3】:

    ConnectionAbortedError: [WinError 10053] 已建立的连接被主机中的软件中止

    如果您正在处理视频,当您在视频上传到数据库时发出另一个请求时,就会发生这种情况。 我建议您在视频标签中使用 preload='none' 或在视频上传时阻止新请求。

    【讨论】:

      【解决方案4】:

      即使使用 Python 3.6.5 和 django 2.0,我也遇到了这个错误

      我注意到浏览器调试器的网络选项卡中出现 301 重定向。当我通过将尾部反斜杠附加到我的 html/js 中的所有 url/api 调用来修复它们时,这个问题就消失了。 urlconf 也必须有尾部反斜杠。

      【讨论】:

      • 你能举个例子吗?
      • 我尝试附加斜杠,但它仍然给我错误。
      【解决方案5】:

      这件事过去发生在我身上: 就我而言: 我首先在Firefox中打开它并遇到了这个错误。 然后我在 Microsoft Edge 中打开它,错误消失了。 尝试这个: 用其他浏览器打开服务器URL,看看结果应该是正常的。

      【讨论】:

        【解决方案6】:

        我遇到了同样的错误:ConnectionAbortedError: [WinError 10053]。 Python 版本:3.8.1

        我重启了电脑,错误消失了

        【讨论】:

        • 我也在重新启动我的计算机,直到我发现它是由于在我的 django 应用程序运行时在我的浏览器中打开了多个选项卡造成的。
        猜你喜欢
        • 2019-01-04
        • 1970-01-01
        • 2021-02-02
        • 1970-01-01
        • 2018-12-12
        • 1970-01-01
        • 2020-05-22
        • 2019-06-25
        • 1970-01-01
        相关资源
        最近更新 更多