-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebClient corrupts binary data when trying to upload many files #27939
Comments
Please, edit the description to provide the full details. A link to StackOverflow is fine in addition, e.g. if there is a relevant discussion, but not as a replacement of a full description on an issue report. |
@rstoyanchev I updated the description with more details. I hope it looks a little better now. |
Yes it does, thanks. I enabled the wiretap setting of the Reactor Netty server to log request details, and also modified the test to send the Base64 encoded strings, so I could compare what was sent, to what was received on the server side, to what is observed in the So I can see there is an issue, but the root cause. @poutsma, will need some help on this. |
Here is example log output on a file part where this occurs:
Note how the Content-Length in the part headers is 36, followed by 2 body buffers emitted. One of 36 bytes, which is the correct length of the sent item. The second of 2 bytes (content is |
I will pick this one up. |
The problem seems to be in All of this occurs in |
@karolkrasnowski Thanks for providing the test case, it made fixing this bug a lot easier! |
@poutsma no problem. Thanks for taking care of this issue! |
I use
WebClient
to upload binary files. When there are only a few of them everything works great, but when there are more (e.g. several hundred),WebClient
sometimes corrupts binary data.I described the problem in more detail in this question on StackOverflow. I also created a repository containing tests that illustrate this issue.
I don't know what is the reason for this behavior but it doesn't seem entirely deterministic.
My use case is that I am sending binary files from one service (let's call it
A
) to another (let's call itB
).This is how I read these binary files in the service
B
:And this is how I send these files in the service
A
(I wrote some tests to better illustrate the issue).As you can see, the only difference between these two tests is the number of files uploaded. The first test always works, and the second one doesn't work most of the time. When I was analyzing why these bytes do not match, I noticed that sometimes a few extra bytes appear at the end (something like padding).
Interestingly, when I use
WebTestClient
, the same problem does not occur, as shown in this test.The text was updated successfully, but these errors were encountered: