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 helps to detect if a request has been forwarded to the same NRF causing an infinite loop. To detect, NRF evaluates the Via header in the incoming requests. If it contains its own host and port, NRF declares a loop has been detected and returns an error response as configured under errorResponses for errorCondition=NRF_Forwarding_Loop_Detection.
- NRF forwarding:
The following image describes the high-level view of NRF forwarding across Segment 1 and Segment 2, where the request is forwarded from one NRF to another and then incorrectly returned to the originating NRF, resulting in loop detection.
Figure I-1 Loop Detection -NRF Forwarding

NRF-A of Segment 1 forwards a request to NRF-E of Segment 2. Due to an incorrect routing or forwarding configuration, the request is routed back to NRF-A. Upon receiving the request, NRF-A detects that the
Viaheader already contains its own configuredhost:port(ocnrfHost:ocnrfPortin{apiRoot}/nrf-configuration/v1/generalOptionsURI) entry. NRF identifies this as a forwarding loop and returns the configured error response (for example,HTTP 508 “Loop Detected”). - NRF Growth forwarding:
The following image describes the high-level view of NRF Growth forwarding across Segment 1 and Segment 2, where each segment contains Set 1 and Set 2, and a returned request reaches the originating NRF again, resulting in loop detection.NRF-A in NRF Set-1 of Segment 1 forwards a request to NRF-E in NRF Set-2 of Segment 2 based on the NRF Growth forwarding configuration. Due to an incorrect routing or forwarding configuration, the request is forwarded back to NRF-A in NRF Set-1 of Segment 1. Upon receiving the request, NRF-A in NRF Set-1 of Segment 1 detects that the
Figure I-2 Loop Detection_NRF Growth Forwarding

Viaheader already contains its own configuredocnrfHost:ocnrfPortentry. NRF identifies this as a forwarding loop and returns the configured error response (for example,HTTP 508 Loop Detected).
Loop Prevention
Loop prevention prevents creation of loops by checking the forwarding history before forwarding a request. Before forwarding a request, NRF compares the entries in the Via header with the configured NRF identities in nrfHostConfig. If the selected destination NRF already appears in the Via header, NRF determines that the destination NRF has already processed the request and skips forwarding to that NRF to prevent a forwarding loop.
- NRF forwarding:
The following image describes the high-level view of NRF forwarding across Segment 1 and Segment 2, where the destination NRF checks the
Viaheader before forwarding and skips sending the request back to an NRF that already processed it.Figure I-3 Loop Prevention_NRF Forwarding

NRF-A in Segment 1 forwards a request to NRF-E in Segment 2. NRF-E in Segment 2 determines that the next forwarding destination is NRF-A in Segment 1. Before forwarding the request, NRF-E in Segment 2 compares the
Viaheader with the configured NRF identities innrfHostConfigand finds that NRF-A in Segment 1's host:port already exists in theViaheader. Since the destination NRF has already processed the request, NRF-E in Segment 2 does not forward the request to NRF-A in Segment 1, thereby preventing a forwarding loop. - NRF Growth forwarding:
The following image describes the high-level view of NRF Growth forwarding across Segment 1 and Segment 2, where each segment contains Set 1 and Set 2, and the destination NRF prevents a loop by skipping forwarding to an NRF already present in the
Viaheader.Figure I-4 Loop Prevention_NRF Growth Forwarding

NRF-A in Segment 1 of NRF Set1 forwards a request to NRF-E in Segment 2 of NRF Set 2. NRF-E in Segment 2 of NRF Set 2 determines that the next forwarding destination is NRF-A in Segment 1 of NRF Set1. Before forwarding the request, NRF-E in Segment 2 of NRF Set 2 compares the
Viaheader with the configured NRF identities undernrfHostConfig.staticNrfConfigList[].nrfHostConfigList[]and finds that NRF-A in Segment 1 of NRF Set 1's host:port already exists in theViaheader. Since the destination NRF has already processed the request, NRF-E in Segment 2 of NRF Set 2 does not forward the request to NRF-A in Segment 1 of NRF Set1, thereby preventing a forwarding loop.