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

378 views
Skip to first unread message

Carlos Chacon

unread,
Dec 29, 2016, 3:17:10 AM12/29/16
to Falcon Framework

Hi Everyone, 

I implemented a API using Falcon, it uses multipart/form to upload a file to my server. When the file is small, the POST request works fine. But when the file is large, the POST fails with below error. Does anyone know what is the problem?

Error:

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


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

Carlos Chacon

unread,
Dec 29, 2016, 3:38:04 AM12/29/16
to Falcon Framework
This is my request (using httpie):

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

Thanks,
Carlos

Jamieson

unread,
Dec 30, 2016, 5:10:59 PM12/30/16
to Falcon Framework
Is your file larger than 1/2 your RAM? file.read() would tend to imply that you're reading the whole thing into RAM. You should probably iterate. (However, the OOM killer would probably kill the entire process on the server side.) You should probably chunk the file read and write. You might also be running into limits if you are proxying via another process (i.e., nginx or similar)


Reply all
Reply to author
Forward
0 new messages