I'm trying to create an app that uses SocketIO through the python flask-socketio package. I have set up my server as such:
File ./run.py
from my_project import app, socketio
if __name__ == '__main__':
socketio.run(app, host='0.0.0.0', debug=True)
File ./my_project/__init__.py
from flask import Flask
from flask_socketio import SocketIO
app = Flask(__name__)
app.config['SECRET_KEY'] = 'MY SECRET KEY'
socketio = SocketIO(app)
@socketio.on('connect')
def print_connect():
print('Client connected')
@socketio.on('disconnect')
def print_disconnect():
print('Client disconnected')
from my_project import views
I was getting "not defined" errors when trying to use it on the client, so I opened the socket.io.js
file that Chrome had retrieved from the server, only to be surprised by the following contents (in their entirety):
�0{"pingTimeout":60000,"sid":"3d6073ff436c49b1aa06090dbb001ceb","upgrades":[],"pingInterval":25000}�40
To double-check that it had nothing to do with my app, I retrieved the file through curl with the command curl 127.0.0.1:5000/socket.io/socket.io.js
which returned the exact same garbled string.
I am not using Express in any fashion (as far as I know), so most of the other questions about sourcing the client socket.io file do not seem to apply. Further, I'm not getting a 404 from the server, I'm getting a 200 and data of some sort.
What can I do to troubleshoot why my server is serving up an obviously corrupted socket.io file?