diff --git a/ydb/library/actors/http/http_proxy.cpp b/ydb/library/actors/http/http_proxy.cpp index 4aad0c9ac19a..7bb3c7e9a1b4 100644 --- a/ydb/library/actors/http/http_proxy.cpp +++ b/ydb/library/actors/http/http_proxy.cpp @@ -127,7 +127,7 @@ class THttpProxy : public NActors::TActorBootstrapped, public THttpC void Handle(TEvHttpProxy::TEvResolveHostRequest::TPtr event, const NActors::TActorContext& ctx) { const TString& host(event->Get()->Host); auto it = Hosts.find(host); - if (it == Hosts.end() || it->second.DeadlineTime > ctx.Now()) { + if (it == Hosts.end() || it->second.DeadlineTime < ctx.Now()) { TString addressPart; TIpPort portPart = 0; CrackAddress(host, addressPart, portPart); @@ -174,6 +174,22 @@ class THttpProxy : public NActors::TActorBootstrapped, public THttpC it->second.DeadlineTime = ctx.Now() + HostsTimeToLive; } } + catch (const TNetworkResolutionError& e) { + if (it != Hosts.end()) { + ctx.Send(event->Sender, new TEvHttpProxy::TEvResolveHostResponse(it->first, it->second.Address)); + return; + } else { + ctx.Send(event->Sender, + new TEvHttpProxy::TEvResolveHostResponse( + TStringBuilder() + << "Resolution failed and no stale cached value has been found to fallback.\n" + << "Resolution error: " + << e.what() + ) + ); + return; + } + } catch (const yexception& e) { ctx.Send(event->Sender, new TEvHttpProxy::TEvResolveHostResponse(e.what())); return;