Skip to content

Commit 1722642

Browse files
committed
fix #2061 add 504 to retriable http status codes
1 parent b690d8a commit 1722642

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

src/Elasticsearch.Net/Responses/ElasticsearchResponse.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public class ElasticsearchResponse<T> : IApiCallDetails
7373
/// </summary>
7474
public bool SuccessOrKnownError =>
7575
this.Success || (HttpStatusCode >= 400 && HttpStatusCode < 599
76+
&& HttpStatusCode != 504 //Gateway timeout needs to be retried
7677
&& HttpStatusCode != 503 //service unavailable needs to be retried
7778
&& HttpStatusCode != 502 //bad gateway needs to be retried
7879
);

src/Tests/ClientConcepts/ConnectionPooling/Failover/FallingOver.doc.cs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Threading.Tasks;
3-
using Elasticsearch.Net;
4-
using Nest;
1+
using System.Threading.Tasks;
52
using Tests.Framework;
63
using static Elasticsearch.Net.AuditEvent;
74

@@ -82,6 +79,30 @@ public async Task Http503FallsOver()
8279
);
8380
}
8481

82+
/**[[service-unavailable]]
83+
*=== 504 Gateway Timeout
84+
*
85+
* Will be treated as an error that requires retrying
86+
*/
87+
[U]
88+
public async Task Http504FallsOver()
89+
{
90+
var audit = new Auditor(() => Framework.Cluster
91+
.Nodes(10)
92+
.ClientCalls(r => r.FailAlways(504))
93+
.ClientCalls(r => r.OnPort(9201).SucceedAlways())
94+
.StaticConnectionPool()
95+
.Settings(s => s.DisablePing())
96+
);
97+
98+
audit = await audit.TraceCall(
99+
new ClientCall {
100+
{ BadResponse, 9200 },
101+
{ HealthyResponse, 9201 },
102+
}
103+
);
104+
}
105+
85106
/**
86107
* If a call returns a valid http status code other than 502 or 503, the request won't be retried.
87108
*

0 commit comments

Comments
 (0)