minio-go: net/http: HTTP/1.x transport connection broken: http: ContentLength=5256549 with Body length 0

on CentOS7,I use the PutObject API to upload my data regularly, about every 10s like this ↓

client.PutObject(context.Background(), bucket, object, reader, 5217066, PutObjectOptions{DisableContentSha256: true}

From time to time an error will appear, perhaps once every few days like this ↓

upload object error:Put \"http://127.0.0.1:19000/000-19534/2/168771633.mp4\": net/http: HTTP/1.x transport connection broken: http: ContentLength=5256549 with Body length 0

but in my log, the data has been read and sized correctly ↓

net/http: HTTP/1.x transport connection broken: http: ContentLength=5217066 with Body length 0" len=0 readFinished=true readHistory=“[32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 6954 -1]” writeFinished=true

What is the cause of this? Thank you very much for your help.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 18 (4 by maintainers)

Most upvoted comments

To summarize:

  • The Reader provided must provide exact the number of bytes in size before it returns io.EOF.
  • If the Reader provided supports io.Seeker it must support it properly, or expect errors.
  • return 0, nil is very bad practice, and will either result in seemingly random errors or hot loops. Use proper synchronization.