Hello im trying to run a flask_socketio application with ssl.
The Code:
if __name__ == '__main__':
socketio.run(app, host="0.0.0.0", port="80", debug=True, ssl_context=context)
The Error:
* Restarting with stat
* Debugger is active!
* Debugger PIN: 102-422-495
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.8/dist-packages/flask_socketio/__init__.py", line 580, in run_server
eventlet.wsgi.server(eventlet_socket, app,
TypeError: server() got an unexpected keyword argument 'ssl_context'
I already tried possible Solutions that were suggested under this question.
However, I cannot figure out how to pass cert into this call. What do I have to do to make this work?
CodePudding user response:
This is a question that applies to the web server that you are using, not to Flask-SocketIO.
Based on your error, you are using the Eventlet web server, which takes certfile
and keyfile
arguments (documentation).
Add these arguments to the socketio.run()
function and Flask-SocketIO will send them to Eventlet.
Example:
if __name__ == '__main__':
socketio.run(app, host="0.0.0.0", port="80", debug=True,
certfile='cert.pem', keyfile='key.pem',
server_side=True)