<p>I have an app hosted on GKE which, among many tasks, serve's a zip file to clients. These zip files are constructed on the fly through many individual files on google cloud storage.</p>

<p>The issue that I'm facing is that when these zip's get particularly large, the connection fails randomly part way through (anywhere between 1.4GB to 2.5GB). There doesn't seem to be any pattern with timing either - it could happen between 2-8 minutes.</p>

<p>AFAIK, the connection is disconnecting somewhere between the load balancer and my app. Is GKE ingress (load balancer) known to close long/large connections?</p>

<p>GKE setup:</p>

<ul>
<li>HTTP(S) load balancer ingress</li>
<li>NodePort backend service</li>
<li>Deployment (my app)</li>
</ul>

<p>More details/debugging steps:</p>

<ul>
<li>I can't reproduce it locally (without kubernetes).</li>
<li>The load balancer logs <code>statusDetails: "backend_connection_closed_after_partial_response_sent"</code> while the response has a 200 status code. A google of this gave nothing helpful.</li>
<li>Directly accessing the pod and downloading using k8s port-forward worked successfully</li>
<li>My app logs that the request was cancelled (by the requester)</li>
<li>I can verify none of the files are corrupt (can download all directly from storage)</li>
</ul>

Taylor Graham
<p>I believe your "backend_connection_closed_after_partial_response_sent" issue is caused by websocket connection being killed by the back-end prematurily. You can see the documentation on <a href="https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_socket_keepalive" rel="nofollow noreferrer">websocket proxying in nginx</a> - it explains the nature of this process. In short - by default WebSocket connection is killed after 10 minutes.</p>

<p>Why it works when you download the file directly from the pod ? Because you're bypassing the load-balancer and the websocket connection is kept alive properly. When you proxy websocket then things start to happen because WebSocket relies on hop-by-hop headers which are not proxied.</p>

<p>Similar <a href="https://stackoverflow.com/a/58019331/12257250">case was discussed here</a>. It was resolved by sending ping frames from the back-end to the client.</p>

<p>In my opinion your best shot is to do the same. I've found many cases with similar issues when websocket was proxied and most of them suggest to use pings because it will reset the connection timer and will keep it alive.</p>

<p>Here's more about <a href="https://uwsgi-docs.readthedocs.io/en/latest/WebSockets.html#ping-pong" rel="nofollow noreferrer">pinging the client using WebSocket</a> and <a href="https://cloud.google.com/load-balancing/docs/https/#timeouts_and_retries" rel="nofollow noreferrer">timeouts</a> </p>

<p>I work for Google and this is as far as I can help you - if this doesn't resolve your issue you have to contact GCP support.</p>
