GeezerVison is showing github.com — GAE websockets support flask-socketio · Issue #2196 · GoogleCloudPlatform/python-docs-samples
GAE websockets support flask-socketio #2196
Labels
🚨This issue needs some love.api: appengineIssues related to the App Engine Admin API API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. Description
In which file did you encounter the issue?
app.yaml
Did you change the file? If so, how?
Nope
Describe the issue
My project is using Flask-Socketio for websocket support.
My entrypoint is: entrypoint: gunicorn supervisor.wsgi:app -k eventlet
I also set network: session_affinity: true
Everything is running except the websocket, I get the following error on Firefox:
Firefox can’t establish a connection to the server at wss://myproject.appspot.com/socket.io/?EIO=3&transport=websocket&sid=500afafea543442dad546cc325ce5def.
There is no such error when running my project with the same command on my computer.
Activity
andrewsg commented on Sep 3, 2019
The samples are built around flask-sockets so that we can leverage the gunicorn flask_sockets.worker, which allows gunicorn to simultaneously serve http and websocket traffic. I don't think socketio on Python is compatible with gunicorn out of the box; you may have to explore alternative webservers to make this work.
I don't know why it's working on your local machine, though. What command are you running locally to start the server?
Altiire commented on Sep 4, 2019
To support web sockets :
sample of supervisor/app.py
def create_app(testing=False, cli=False):
"""Application factory, used to create application
"""
app = Flask('supervisor')
CORS(app)
app.config.from_object('supervisor.config')
if testing is True:
app.config['TESTING'] = True
force_auto_coercion()
configure_extensions(app, cli)
register_blueprints(app)
socketio.init_app(app)
return app
if __name__ == '__main__':
app = create_app()
socketio.run(app)
If I remember well, the socket was working on GAE in July, and not now as I just checked
I don't think socketio on Python is compatible with gunicorn out of the box; you may have to explore alternative webservers to make this work.
The eventlet worker is supposed to support socketio
added
priority: p2Moderately-important priority. Fix may not be included in next release. type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed
🚨This issue needs some love. on Nov 15, 2019andrewsg commented on Mar 9, 2020
Closing this as we don't currently have a good solution for adding support for both socketio and other strategies in the same sample on Python, and it's not a bug in an existing sample.
Metadata
Metadata
🚨This issue needs some love.api: appengineIssues related to the App Engine Admin API API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. Development
No branches or pull requestsIssue actions