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

我正在为 django 和 django-rest 编写一个 API。我曾经在 ubuntu 上开发它,但是当我切换到 windows 时,我开始在 django 的每个响应中收到这些错误。

Exception happened during processing of request from ('127.0.0.1', 54161)
Traceback (most recent call last):
  File "C:\Users\Admin\anaconda3\envs\project\lib\socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "C:\Users\Admin\anaconda3\envs\project\lib\socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "C:\Users\Admin\anaconda3\envs\project\lib\socketserver.py", line 720, in __init__
    self.handle()
  File "C:\Users\Admin\anaconda3\envs\project\lib\site-packages\django\core\servers\basehttp.py", line 174, in handle
    self.handle_one_request()
  File "C:\Users\Admin\anaconda3\envs\project\lib\site-packages\django\core\servers\basehttp.py", line 182, in handle_one_request
    self.raw_requestline = self.rfile.readline(65537)
  File "C:\Users\Admin\anaconda3\envs\project\lib\socket.py", line 669, in readinto
    return self._sock.recv_into(b)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine

开发人员工具还显示此连接已取消。我禁用了防火墙和防病毒程序。

这是我/etc/hosts/中唯一的林

127.0.0.1   localhost.localdomain localhost

我使用的是 Windows 10。

Python              3.86
Django              3.1.2
django-cors-headers 3.5.0
djangorestframework 3.12.1

你知道如何解决这个问题吗?

【问题讨论】:

    标签: python django google-chrome django-rest-framework


    【解决方案1】:

    问题在于客户端的超时。默认情况下,某些浏览器设置的超时数非常小(在我的情况下为 1 秒)。当服务器无法处理请求时,连接中止。

    我已通过将超时设置为 5s 来修复它。

    【讨论】:

    • 你是如何调整超时时间的?
    • 我使用axios 作为进行 REST 调用的库。在那里,我刚刚调整了主配置 ` timeout: 5 `
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-04
    • 2019-06-25
    • 2021-11-12
    • 1970-01-01
    • 1970-01-01
    • 2015-06-25
    • 2018-12-12
    相关资源
    最近更新 更多