0

I'm getting the following when sending a very large POST to a Flask application.

Logs:

restful stderr | /usr/local/lib/python2.7/dist-packages/werkzeug/filesystem.py:63: BrokenFilesystemWarning: Detected a misconfigured UNIX filesystem: Will use UTF-8 as filesystem encoding instead of 'ANSI_X3.4-1968'
  BrokenFilesystemWarning)
restful stderr | 172.19.0.5 - - [25/Apr/2017 00:05:40] "POST /ml/source/ HTTP/1.1" 500 -
restful stderr | Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/opt/fish/bizco/ml/restful.py", line 49, in index
    job = q.enqueue_call(func=process_request, args=(postObject,), result_ttl=5000, timeout=36000)
  File "/usr/local/lib/python2.7/dist-packages/rq/queue.py", line 216, in enqueue_call
    job = self.enqueue_job(job, at_front=at_front)
  File "/usr/local/lib/python2.7/dist-packages/rq/queue.py", line 282, in enqueue_job
    pipe.execute()
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 2641, in execute
    return execute(conn, stack, raise_on_error)
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 2495, in _execute_transaction
    connection.send_packed_command(all_cmds)
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 556, in send_packed_command
    (errno, errmsg))
ConnectionError: Error 104 while writing to socket. Connection reset by peer.

Route Code:

@app.route('/zebra/', methods=['GET', 'POST'])
def index():
    print "/zebra/ called:")
    if request.method == "POST": 
        state = True
        if request.headers['Content-Type'] == 'application/x-msgpack':
            print 'Found MsgPack'
            postObject   = msgpack.unpackb(request.data)
        else:
            print 'Content type not correct'
            state = False
        if state == True:
            json = jsonify(...)
        else:
            # return an error
            json = jsonify...)
        return json

The POST object contains a MessagePack encoded payload, but it never enters my route handler. I see no log statement inside the handler block.

This only seems to happen when the payload is above 200MB. How do I get flask to store handle properly?

Philip Kirkbride
  • 21,381
  • 38
  • 125
  • 225
Jack Murphy
  • 2,952
  • 1
  • 30
  • 49
  • 1
    Can you reproduce this error when running the application outside of docker, but otherwise identically behind nginx etc? It might be worth ruling out exactly what part of your stack causes this issue. – Gareth Pulham Apr 25 '17 at 00:24
  • 1
    Let me clear up the post - i am able to reproduce when running without docker / nginx – Jack Murphy Apr 25 '17 at 00:27
  • 1
    The traceback shows an error related to the `/ml/source` route, and then with entering data into a queue managed by redis. Is your connection with redis happy with taking 200MB payloads? – Gareth Pulham Apr 25 '17 at 00:34

0 Answers0