WinError 10053
Django 运行报错
项目运行时出现 ConnectionAbortedError: [WinError 10053] 你的主机中的软件中止了一个已建立的连接,但程序仍然正常运行,真的是逼死强迫症。
更改ajax异步
Ajax默认为异步提交,将Ajax更改为同步提交方式,在Ajax中加上***async:false,***
$.ajaxSetup{
async:false
}
或是
$.ajax({
url:"http://127.0.0.1:8000/userctrl/orders",
data:{'user':$.cookie("username")},
type:"post",
*async:false,*
dataType:"text",
success:function(obj){
})
})
重写SocketWriter类
找到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
以上两种方法都是百度而来,但均没有解决我的问题,后来看到了这篇文章给了我启发,检查代码
<a class="text-decoration-none" href="{% url '' %}">
<button type="button" class="btn btn-warning" id="reload">
新增
</button>
</a>
发现button同时绑定了一个location.reload()导致出现WinError 10053,去除事件后没有再报错
本文介绍了在Django项目中遇到的ConnectionAbortedError: [WinError 10053]错误,分析了错误原因可能是ajax异步问题或SocketWriter类的写入方法。尝试通过改变ajax同步设置和重写SocketWriter类的方法来解决问题,但最终发现是button的location.reload()事件导致的问题,移除该事件后解决了错误。
1469

被折叠的 条评论
为什么被折叠?



