I Loop Detection and Loop Prevention in NRF Forwarding Scenarios
NRF forwarding may
involve multiple NRFs. Since
nrfHostConfig defines the NRF peers used for forwarding, NRF also uses it together with the
Via header (forwarding history) to ensure that forwarded requests
do not circulate between NRFs.
- NRF forwarding : URI-
{apiRoot}/nrf-configuration/v1/forwardingOptions - NRF Growth forwarding: URI-
{apiRoot}/nrf-configuration/v1/nrfGrowth/nrfForwardingOptions
Loop detection
Loop detection stops a request when it has been forwarded in a circle and
returns to the same NRF endpoint.
NRF checks the Via
header and if it contains the current NRF host and port, NRF declares a loop and returns an error
response as configured under errorResponses for
errorCondition=NRF_Forwarding_Loop_Detection.
- NRF forwarding: NRF-A forwards a request to NRF-B. Due to routing or
configuration issues, NRF-B forwards the same request back to NRF-A. When NRF-A
receives it again, the
Via headeralready contains NRF-Ahost:port, so NRF-A detects a loop and returns the configured error (for example,HTTP 508 “Loop Detected”). - NRF Growth forwarding: NRF-A forwards a request from the NRF set-1 to another
NRF (NRF-E) in the NRF set-2 based on Growth forwarding configuration. Due to
routing or configuration issues, the request is forwarded back to the original
NRF (NRF-A) in the first NRF set (NRF set-1). When the original NRF (NRF-A in
NRF set-1) receives it again, the
Via headeralready contains the original NRF (NRF-A in NRF set-1)host:port, so it detects a loop and returns the configured error (for example,HTTP 508 “Loop Detected”).
Loop prevention
Loop prevention avoids repeated forwarding by ensuring NRF does not forward a request that is
already forwarded. NRF compares the
Via header against configured NRF identities in
nrfHostConfig; if it matches, NRF treats the request as already
forwarded and does not forward it again.
- NRF forwarding: A request reaches an NRF with a
Via headerentry that matches a configuredhost:portinnrfHostConfig. NRF treats the request as already forwarded and does not forward it again. - NRF Growth forwarding: A request reaches an NRF with a
Via headerentry that matches a configuredhost:portundernrfHostConfig.staticNrfConfigList[].nrfHostConfigList[]. NRF treats the request as already forwarded and does not forward it again.