连接flask-socketio时加载html源文件时出错

时间:2018-04-16 10:08:44

标签: python flask-socketio eventlet

我正在使用socket.io js(客户端)并连接到flask-socketio(服务器)。 连接发生,但在我的HTML中加载源文件时,我在python中收到错误。所以它试图首先加载源文件,然后进行套接字连接:

  window.addEventListener('load', function(){
    //Socket initial connection
    var socket = io('http://'+ document.domain + ':' + location.port);  
  })

但是,我仍然在python中遇到此错误:

127.0.0.1 - - [16/Apr/2018 12:47:16] "GET 
/static/video/video.mp4 HTTP/1.1" 200 1835327 0.771649
Traceback (most recent call last):
File "C:\Users\Dave\AppData\Local\Programs\Python\Python36\lib\site-packages\eventlet\hubs\selects.py", line 55, in wait
listeners.get(fileno, noop).cb(fileno)
File "C:\Users\Dave\AppData\Local\Programs\Python\Python36\lib\site-packages\eventlet\greenthread.py", line 218, in main
result = function(*args, **kwargs)
File "C:\Users\Dave\AppData\Local\Programs\Python\Python36\lib\site-packages\eventlet\wsgi.py", line 781, in process_request
proto.__init__(conn_state, self)
File "C:\Users\Dave\AppData\Local\Programs\Python\Python36\lib\site-packages\eventlet\wsgi.py", line 337, in __init__
self.finish()
File "C:\Users\Dave\AppData\Local\Programs\Python\Python36\lib\site-packages\eventlet\wsgi.py", line 695, in finish
BaseHTTPServer.BaseHTTPRequestHandler.finish(self)
File "C:\Users\Dave\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 760, in finish
self.wfile.close()
File "C:\Users\Dave\AppData\Local\Programs\Python\Python36\lib\socket.py", line 604, in write
return self._sock.send(b)
File "C:\Users\Dave\AppData\Local\Programs\Python\Python36\lib\site-packages\eventlet\greenio\base.py", line 394, in send
return self._send_loop(self.fd.send, data, flags)
File "C:\Users\Dave\AppData\Local\Programs\Python\Python36\lib\site-packages\eventlet\greenio\base.py", line 381, in _send_loop
return send_method(data, *args)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
Removing descriptor: 1656

从跟踪看起来似乎涉及到了eventlet。在我的python程序的顶部,我有gevent:

from gevent import monkey
monkey.patch_all() #must be on top

我不确定是什么导致了这个问题。如何解决此错误?

0 个答案:

没有答案