-
Notifications
You must be signed in to change notification settings - Fork 40.8k
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
Duplicate "Transfer-Encoding: chunked" header #37646
Comments
Thanks for the report. Unfortunately, it's not clear to me why you believe this is a Spring (Boot) issue. As explained in the Framework issue to which you have already linked, the If you believe that Spring is the cause of the problem that you're seeing and you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue. |
I understand. I just hope someone can point me to right direction. I don't think we are touching the headers anywhere else in the app code, and further investigation is not trivial since the errors starts occurring for unknown reason only in the production environment. Any tips, how to debug this or what can cause this are appreciated. |
Perhaps you could add a |
So I've added such debug logging filter, and I can confirm, we are not adding the header in the application code. So it has to be added after the filter chain is done. |
Thanks for trying the filter. That points towards the web server being the most likely cause of the problem. I suspect you're using Tomcat so I think your next step should be to raise this with Tomcat's maintainers. I'd start with the users mailing list, asking for some further advice on how to narrow down the problem. |
@JanCizmar can you please elaborate more for me on what needs to be fixed please |
@itsayopapi Well, I think I elaborated well. 😆 Can you describe, what's unclear? |
@JanCizmar I cant seem to clone into the repo and also the source code which needs to be fixed |
Hey! Maybe you can join your slack on https://tolg.ee/slack so we don't spam this thread? Thanks for willingness to contribute btw 🚀 |
I facing the same problem: 502 randomly, since a while. Use spring boot 2.7 version and k8s nginx/1.21.6 :( I found this answer, will try it |
I've tried the solution from StackOverflow but it doesn't help. It seems unrelated to this. I've checked the nginx source and there's no way to bypass the check for duplicated header. Currently, I am trying to update to Spring Boot 3. It has the latest Tomcat. If it doesn't help, I will ask in Tomcat community. |
Hi @JanCizmar, |
Hi @sky-philipalmeida , |
In my case, I already fixed this bug. It's related to my server "forwards" the header "Connection" from another upstream server to downstream application. Removed this header forwarding resolves pb. |
I have the same issue. Upstream server produces 1 header and when I forward it, it gets duplicated by Spring. When I filter it out, there is no header. |
@jakub-blazej-telekom Please see my comment above. If you have evidence that Spring is duplicating the header and can provide a sample that reproduces this behavior then please share it with us and we'll be happy to re-open the issue and investigate. Without such evidence, we still believe that the problem lies in the underlying web server and that it will have to be addressed there. |
sorry, I missed that. Here you go: header-demo.zip
|
@jakub-blazej-telekom I believe this issue comment is relevant. Your web endpoint should never add this header in the first place, as only the web server is in charge of such headers. If your application is proxying calls to a another REST endpoint, it should clean up the response headers before forwarding them (that's what proxies do). This applies not only to |
posting this in a couple spring issues on this topic in the hopes it helps others. the best writeup of this problem i've encountered is https://knowledge.broadcom.com/external/article/298108/too-many-transfer-encodings-502-chunked.html. Trigger number 3 in that article was our problem
@Hollerweger 's comment in spring-projects/spring-framework#21523 (comment) provides an alternative that avoided this problem for us.
|
I am getting duplicate
Transfer-Encoding: chunked
headers, which causes my Nginx Ingress Controller to return 502. Weird thing about this: it starts happening randomly after the spring boot instance runs for some time. When the specific pod is restarted, it works fine again.Full error message from Nginx Ingress controller:
The sensitive handler method 1 code. The sensitive handler method 2 code
I am not sure whether it only happens to these 2 endpoints. They are executed very frequently and have bigger responses.
SpringBoot version: 2.7.13
Nginx.com Ingress version: 0.18.1
(I don't think it's related to this), since I don't work with response entities returned from http client.
The text was updated successfully, but these errors were encountered: