How to fix ERR_INVALID_CHUNKED_ENCODING error?
Asked Answered
D

1

7

I have a Clojure application that acts as a proxy service. The goal is to proxy requests to http://127.0.0.1:3000 (Grafana service) through the path "/grafana", so that if I access http://127.0.0.1/grafana through the browser, it should proxy my request to port 3000 and display the UI for Grafana.

The issue I'm running into is that I get an ERR_INVALID_CHUNKED_ENCODING response in the browser. In Wireshark, requests to port 3000 show that the HTTP response reassembles 3 TCP packets. However, the response for requests going through my proxy are not being reassembled, resulting in the chunking error. Anyone have any ideas on how to resolve this?

Thanks.

Dissuasion answered 7/4, 2018 at 11:42 Comment(0)
D
24

The issue was caused when returning the response from my proxy service to the browser. The response contained the header Transfer-Encoding: chunked. This header was necessary when the response went from Grafana -> proxy-service, but not required when going from proxy-service -> browser. So the solution was to remove that header before sending the response back to the browser.

Dissuasion answered 9/4, 2018 at 11:30 Comment(3)
I ran in to the exact same problem myself!Dicker
@Dicker I'm glad this helped you :)Dissuasion
I was getting a net::ERR_HTTP2_PROTOCOL_ERROR in Chrome on the other side of an AWS ALB, but it turned out the underlying cause (that the ALB hid from us) was the Transfer-Encoding header.Adolphadolphe

© 2022 - 2024 — McMap. All rights reserved.