Socket.io POST Requests from Socket.IO-Client-Swift Socket.io POST Requests from Socket.IO-Client-Swift flask flask

Socket.io POST Requests from Socket.IO-Client-Swift


I assume you have verified that Apache does get the POST requests. That should be your first test, if Apache does not log the POST requests coming from iOS, then you have a different kind of problem.

If you do get the POST requests, then you can add some custom code in the middleware used by Flask-SocketIO and print the request data forwarded by Apache's mod_wsgi. The this is in file flask_socketio/init.py. The relevant portion is this:

class _SocketIOMiddleware(socketio.Middleware):    # ...    def __call__(self, environ, start_response):        # log what you need from environ here        environ['flask.app'] = self.flask_app        return super(_SocketIOMiddleware, self).__call__(environ, start_response)

You can find out what's in environ in the WSGI specification. In particular, the body of the request is available in environ['wsgi.input'], which is a file-like object you read from.

Keep in mind that once you read the payload, this file will be consumed, so the WSGI server will not be able to read from it again. Seeking the file back to the position it was before the read may work on some WSGI implementations. A safer hack I've seen people do to avoid this problem is to read the whole payload into a buffer, then replace environ['wsgi.input'] with a brand new StringIO or BytesIO object.


Are you using flask-socketio on the server side? If you are, there is a lot of debugging available in the constructor.

socketio = SocketIO(app, async_mode=async_mode, logger=True, engineio_logger=True)


matomo