2013-07-25 153 views
16

如果我对摇瓶编码,然后我有时会收到此错误:错误:[错误10053]

Traceback (most recent call last): 
    File "C:\Python27\lib\SocketServer.py", line 284, in _handle_request_noblock 
    self.process_request(request, client_address) 
    File "C:\Python27\lib\SocketServer.py", line 310, in process_request 
    self.finish_request(request, client_address) 
    File "C:\Python27\lib\SocketServer.py", line 323, in finish_request 
    self.RequestHandlerClass(request, client_address, self) 
    File "C:\Python27\lib\SocketServer.py", line 640, in __init__ 
    self.finish() 
    File "C:\Python27\lib\SocketServer.py", line 693, in finish 
    self.wfile.flush() 
    File "C:\Python27\lib\socket.py", line 303, in flush 
    self._sock.sendall(view[write_offset:write_offset+buffer_size]) 
error: [Errno 10053] ��������� �� ����� ����- 

任何想法,为什么会发生这种事(win8的64位,python27 X32)?

+1

当你发现这个错误时,你到底在做什么? – Johnsyweb

+1

工作:) - 谷歌浏览器+ pycharm,我没有firewolls,反病毒等。 –

+0

在app.run,app.run(threaded = True)中为我加入threaded = True。 –

回答

18

Windows Sockets Error Codes列表:

WSAECONNABORTED 10053
Software caused connection abort.
An established connection was aborted by the software in your host computer, possibly due to a data transmission time-out or protocol error.

有超时或其他网络级的错误。这是关闭套接字的操作系统,与Python或Flask无关,真的。

它可能是远程浏览器停止响应,网络连接中断,或防火墙关闭了连接,因为它打开时间过长或其他原因。

+0

但我并没有firewolls,反病毒等 –

+4

我列出*一些*的可能性。 –

+0

我知道,但为什么我得到这个错误? :( –

4

我最近在尝试使用Flask提供音频文件时遇到了此错误消息。每当客户端在流结束前关闭流时,我都会收到此错误消息。 Flask继续尝试将数据写入流,但由于底层套接字已断开连接,所以它不能。实际上,这本身不是错误,而是一条消息,通知您在Flask完成将数据写入数据流之前与客户端的连接已关闭。

2

从Web服务器读取响应时遇到此问题。对我而言,问题在于我太早关闭套接字连接,导致通信中断。 因此,我在接收数据之前睡了几秒钟,然后关闭套接字连接。

time.sleep(10) 
data = s.recv(1024) 
s.close() 

它适用于我。

0

这是PIPE错误,如果服务器响应请求并且客户端已关闭连接,则会发生这种错误。浏览器有时会根据使用情况来做。 你可以忽略那些适合生产的网络服务器。

1

我刚刚经历了完全相同的问题。与最高的答案相反,这个问题与Python和Flask有很大关系,它不是Windows的问题。 非常容易重现:

  • 单击烧瓶应用程序中的链接,然后导航到另一页,同时第一个页面仍在加载。每次出现错误并且应用程序崩溃(需要重新启动)
  • 如果我允许服务器完全返回页面,则问题从不会发生。

另外,例如,瓶子微框架从未发生过这种情况。

如果我找出如何解决这个问题,我会让你知道

+0

如承诺的,这里是解决方案:http://stackoverflow.com/questions/40247025/flask-socket-error-errno-10053-an-established-connection-was-aborted-by-the –

8

你好, 这是使用Python 2执行的SocketServer模块的问题,它不存在在Python 3(服务器在哪里继续提供服务)。

Your have 3 options:

Don't use the built-in server for production systems (it is a development server after all). Use a proper WSGI server like gunicorn or uWSGI.

Enable threaded mode with app.run(threaded=True); the thread dies but a new one is created for future requests,

Upgrade to Python 3.

所以每当有,如果你有一个像app.run(螺纹= TRUE)做错误,如

error: [Errno 10053] An established connection was aborted by the software in your host machine 

服务器将重新启动。

+1

使用python 3.6,我很喜欢这个错误。任何线索为什么? – EduardoMaia