http: error: ConnectionError: ('Connection aborted.', error(32, 'Broken pipe')) while doing POST request to URL:

4.1k views Asked by At

I implemented a API using Falcon, it uses multipart/form to upload a file to my server. When the file is small (~1MB), the POST request works fine. But when the file is large (~20MB), the POST fails with below error.

Any feedback on how to fix this issue?

Error:

http: error: ConnectionError: ('Connection aborted.', error(32, 'Broken pipe')) while doing POST request to URL: http://...:49160/api/upload

This is my request command line: Using httpie:

http -f POST http://111.111.111.111:49160/api/upload filename=video.mp4 file@/home/chacon/video.mp4

This is my on_post function:

def on_post(self, req, resp):


    in_file       = req.get_param('file')

    in_video_name = in_file.filename

    source_video_path = os.path.join("/tmp", in_video_name)



    #working, but fails for large files

    with open(source_video_path, 'wb') as source_video_file:

        source_video_file.write(in_file.file.read())

Thanks,

Carlos

1

There are 1 answers

0
Carlos Chacon On

this was a problem with the gunicorn worker timing out. when you launch gunicorn you can specificy the timeout as an argument to make it longer and give enough time for the file to finish uploading