CloudFlare Stream Uploading with TUS stops with 408

Hi, we use CloudFlare Stream and upload video files with python’s tus client lib.

We observed that large file (1GB ~) couldn’t be uploaded, with status code of 408.

This error is reported also in js client of the lib below.

So, I’d like to know what conditions let CloudFlare Stream return 408.
And, once we received 408, what should we do for uploading? (retry or destroy)

I look forward to hearing the answer.

What is the chunksize in your code?

Thanks for reply.

We tried 5242880 ( as sample in document ) and 20MB, then we observed the error in both cases.

And also we tried retry options, but uploading was failed.

        uploader = tus_client.uploader(
            file_path=path_to_file,
            chunk_size=CLOUD_FLARE_CHUNK_SIZE,
            retries=TUS_RETRY_COUNT,
            retry_delay=TUS_RETRY_DELAY_SEC,
        )

Small video file was ok, so I think that file-size causes the status code 408.

Thank you. I did a bit of digging and see a similar issue reported and on the link you provided see a retry works, allbeit inconsistently it seems. I’ve added myself to the issue and will keep track of progress. Is seems like chunksize is set correctly. As I recall, videos larger than 5 MB the minimum chunk size is 5 MB and smaller than 5 MB set chunk size to 5 MB for upload in one step.

Thank you.

I’m sorry, I wrote on github that retry-options enable uploading, but after that some challenges still failed.
So, we have to research the cause.

Cloud you tell me whether video file-size affects CloudFlare Stream’s response time or not?

I suspect that large upload-offset by TUS uploading causes the response delay.

1 Like

Hi, to resolve this problem, I modified the TUS python client and measured each chunk uploading.

Here are samples of my experiment, which are succeeded cases.

offset 5242880 uploaded in 2.61 sec
offset 10485760 uploaded in 5.92 sec
offset 15728640 uploaded in 8.46 sec
 ...

offset 487587840 uploaded in 285.59 sec
offset 492830720 uploaded in 288.34 sec
offset 497135781 uploaded in 317.77 sec
Last chunk uploading takes 29 sec
offset 5242880 uploaded in 2.69 sec
offset 10485760 uploaded in 5.39 sec
offset 15728640 uploaded in 8.28 sec
 ...

offset 487587840 uploaded in 274.67 sec
offset 492830720 uploaded in 277.00 sec
offset 497135781 uploaded in 306.38 sec
Last chunk uploading takes 29 sec

I found that each chunk (of size: 5242880) are uploaded in average of about 3 seconds, but the last chunk uploading of the video takes 30 seconds, such above.

And sometimes the last chunk uploading failed with 408.
Conversely, I haven’t observed 408 error, instead of the last chunk.

And this is the log of failed case.

offset 5242880 uploaded in 3.48 sec
offset 10485760 uploaded in 6.10 sec
offset 15728640 uploaded in 9.06 sec
 ...
offset 1106247680 uploaded in 654.75 sec
offset 1111490560 uploaded in 657.41 sec
offset 1116733440 uploaded in 660.18 sec
Error! at 691.70 sec
Last chunk uploading takes 31 sec

In this measurement, I set client side timeout to 150 sec, with below.

import socket
socket.setdefaulttimeout(150)  # http.client.HTTPSConnection refer this

30 seconds is the threshold to judge timeout on server side?

So, could you tell me what we should do for stable last chunk uploading?