我尝试使用gevent.pywsgi
WSGIServer
运行一个简单的启用SSL的应用程序。但是,在我提出第一次请求后,我会在大约10-15秒之后(从Chrome)获得SSLError: [Errno 8] _ssl.c:510: EOF occurred in violation of protocol
,我认为这是尝试重新握手:
Traceback (most recent call last):
File "D:\SOMEPATH\lib\site-packages\gevent\greenlet.py", line 327, in run
result = self._run(*self.args, **self.kwargs)
File "D:\SOMEPATH\lib\site-packages\gevent\server.py", line 102, in wrap_socket_and_handle
ssl_socket = self.wrap_socket(client_socket, **self.ssl_args)
File "D:\SOMEPATH\lib\site-packages\gevent\ssl.py", line 383, in wrap_socket
ciphers=ciphers)
File "D:\SOMEPATHK\lib\site-packages\gevent\ssl.py", line 94, in __init__
self.do_handshake()
File "D:\SOMEPATH\lib\site-packages\gevent\ssl.py", line 305, in do_handshake
return self._sslobj.do_handshake()
SSLError: [Errno 8] _ssl.c:510: EOF occurred in violation of protocol
<Greenlet at 0x4998850: <bound method WSGIServer.wrap_socket_and_handle of <WSGIServer at 0x499d6d0 fileno=500 address=127.0.0.1:12344>>(<socket at 0x49f50d0 fileno=912 sock=127.0.0.1:123, ('127.0.0.1', 6398))> failed with SSLError
页面加载得很好。我的最小工作示例如下:
from gevent import monkey
monkey.patch_all()
from gevent import ssl
from flask import Flask
from gevent.pywsgi import WSGIServer
app = Flask(__name__)
@app.route('/')
def main():
return 'hi!'
server = WSGIServer(
('127.0.0.1', 12344),
app,
keyfile='server.key',
certfile='server.crt',
ssl_version=ssl.PROTOCOL_TLSv1,
)
print 'Serving..'
server.serve_forever()
gevent
内置服务器 没有错误,SSL设置的方式类似于{{3} }。SSL_ERROR_WANT_READ
&#34;异常&#34;之后的包装C函数。在do_handshake()
处理。我现在在Windows计算机上使用gevent==1.0.1
和Python 2.7.8 (default, Jun 30 2014, 16:03:49)
。
如何摆脱这个错误?