I am trying to set up a small server to handle HTTP and socketio requests -- I don't have much experience setting up servers, but right now apache2 serves the http just fine. The socketio transactions, however, keep failing with error code 400 (bad request), and I see some strange errors in the server logs. Sometimes I see an engineio error and the server responds w/ a 'bad request' and code 400, but always it tells me the eventlet server needs to be started:
[Mon Jan 11 19:02:54.068282 2016] [:error] [pid 4908:tid 140274923673344] [client 100.96.180.39:53473] return ws(environ, start_response)
[Mon Jan 11 19:02:54.068305 2016] [:error] [pid 4908:tid 140274923673344] [client 100.96.180.39:53473] File "/var/www/projectENV/lib/python2.7/site-packages/engineio/async_eventlet.py", line 10, in __call__
[Mon Jan 11 19:02:54.068342 2016] [:error] [pid 4908:tid 140274923673344] [client 100.96.180.39:53473] raise RuntimeError('You need to use the eventlet server.')
[Mon Jan 11 19:02:54.068380 2016] [:error] [pid 4908:tid 140274923673344] [client 100.96.180.39:53473] RuntimeError: You need to use the eventlet server. See the Deployment section of the documentation for more information.
[Mon Jan 11 19:02:54.253124 2016] [:error] [pid 4909:tid 140274940458752] WARNING:engineio:Invalid session cde3f9aadbee4794bf9d7bb98d0b396e
My server code is pretty basic:
from flask import Flask
import flaskext.couchdb
from flask.ext.socketio import SocketIO
# for socketio
import eventlet
eventlet.monkey_patch()
# creation of server & db objects
app = Flask(__name__)
# socketio initialization
socketio = SocketIO(app, async_mode='eventlet')
# import views once site properties are set
from app import views
if __name__== "__main__":
socketio.run(app, debug=True)
And my client code, written in python, uses the socketio-client library straight from the docs:
from socketIO_client import SocketIO, LoggingNamespace
with SocketIO(SERVER_URL, 80, LoggingNamespace) as socketIO:
socketIO.emit('aaa')
socketIO.wait(seconds=1)
Isn't the socketio.run(app)
supposed to start the eventlet server for me? Why is the server spitting back bad request (sometimes)?