SanS
SanS

Reputation: 425

GCP load balancer 502 server error and "backend_connection_closed_before_data_sent_to_client" IIS 10

I have GCP load balancer with 4 IIS 10 web servers. Sporadically it comes with 502-Server error. In the logs it shows it is because of backend_connection_closed_before_data_sent_to_client. I have read thru the article https://cloud.google.com/compute/docs/load-balancing/http/ and it says keepalive timout need to be set to 620 seconds for nginx and apache. How do I do the same in IIS 10.

Upvotes: 3

Views: 9035

Answers (3)

Mark Pevec
Mark Pevec

Reputation: 131

I ran into a similar problem and found I needed to raise the keep alive timeout of the backend service (Nodejs in my case and this value: https://nodejs.org/docs/latest/api/http.html#serverkeepalivetimeout)

We raised from the default 5s to the 620s recommended here (point #4): https://cloud.google.com/load-balancing/docs/https/troubleshooting-ext-https-lbs#unexplained_5xx_errors

Upvotes: 0

SanS
SanS

Reputation: 425

Figured this out after raising a ticket google cloud team. I am putting it here so that others can benefit.

Step 1 : Set the timeouts in Google Cloud Load Balancer

There are two timeout settings in Google cloud load balancer.

  1. Timeout and
  2. Connection draining timeout.

See the screenshot below. Load balancer settings

Both the above settings need to be the same. In our case, there are a number of long running requests and it is set to 1800 seconds.

Step 2: Set the connection timeout in IIS 20 second greater than the load balancer setting

Under IIS Site name - go to Advanced settings and then set the Connection Time-out value to 20 seconds more than the load balancer timeout. In my case 1820.

IIS Settings

The idea is that the IIS connection should not timeout before load balancer. If it times out then it may leads to backend_connection_closed_before_data_sent_to_client error.

Upvotes: 10

Pnkj
Pnkj

Reputation: 11

You can set this in web.config as execution time out attribute in http runtime by default when you set keep alive it sets time out to 120 seconds .If still doesn’t work then may be there is proxy server between your request response process . You have to check that proxy server time out.

I faced the same scenario in gcp and I have setted everything in load balancer level but did not work . Then I found that there was an proxy server between our process . Let me know if you can tell in more detail

Upvotes: 1

Related Questions