Deploying Flask Socket.io application with eventlet on Google AppEngine

1,054 views
Skip to first unread message

Matthew Ha

unread,
May 4, 2020, 4:40:03 AM5/4/20
to Google App Engine
I am using flask socket.io configured with eventlet on a flexible google appengine instance. According to the flask socket.io documentation: https://flask-socketio.readthedocs.io/en/latest/ running `socketio.run(app)` will start a webserver if eventlet is installed. 

I have a local react web app attempting to establish a WebSocket connection with this app engine instance. The web app uses socket.io and initially defaults to polling HTTP requests. These requests all timeout-- I'm unable to establish a web socket connection. I'm not sure what might be causing my issue, whether it is my app engine configuration or my flask socket.io setup.

Here is my initialization code for flask socket.io:

    app = Flask(__name__)
    socketio
= SocketIO(app)
    socketio
.init_app(app, cors_allowed_origins="*")
   
..
   
..
   
if __name__ == '__main__':
        socketio
.run(app, debug=True)

    

Here is my app.yaml:

    runtime: python


    env
: flex


    entrypoint
: python3 server.py


    runtime_config
:
      python_version
: 3


    manual_scaling
:
      instances
: 1


    network
:
      session_affinity
: true


Here is the web app code attempting to set up the connection:
    import io from 'socket.io-client'
   
const socketURL = "<app-engine-instance-url>:5000"
   
const socket = io.connect(socketURL)



Katayoon (Cloud Platform Support)

unread,
May 4, 2020, 12:18:42 PM5/4/20
to Google App Engine
Hi Matthew,

I see you have already posted your question on Stack Overflow. I recommend to continue with the thread in Stack Overflow in order to avoid duplicating effort. 

Note that, Google Groups are reserved for general questions on Google Cloud Platform-end products and for technical issues you should post your full detailed question on Stack Overflow. 


Reply all
Reply to author
Forward
0 new messages