FreeRTOS TCP - vApplicationIPNetworkEventHook called in the middle of the application with xNetworkUp as true

I’m running the MQTT Agent demo application on my board and after a long period of successful MQTT publishing I suddenly see a call to vApplicationIPNetworkEventHook(true) that cause the application to run on top of the previous invocation and from here I get hard fault.

What event can cause this?

On the log I see this:

vDHCPProcess: reply c0a80037ip
vDHCPProcess: offer c0a80037ip
vDHCPProcess: acked c0a80037ip
[INFO] [MQTTApp] [main.c:614] IP Address: 192.168.0.55
[INFO] [MQTTApp] [main.c:617] Subnet Mask: 255.255.255.0
[INFO] [MQTTApp] [main.c:620] Gateway Address: 192.168.0.1
[INFO] [MQTTApp] [main.c:623] DNS Server Address: 192.168.0.1

In the middle of a normal application log.

The DHCP server should provide a lease time, after which the DHCP process repeats. Normally the DHCP server will give the same address again. Could that be what you are seeing here? Do you know the lease time - you will be able to view it if you look at the DHCP packets in Wireshark (or just see it in the code https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/FreeRTOS_DHCP.c#L996 ).

OK, I checked this and it is half an hour and indeed it might be the cause for the event I see but should this cause the application to rerun on itself?

The vApplicationIPNetworkEventHook is being trigged by this event and I assume the eNetworkEvent is true as otherwise the function would have been return with no action, and since it is passed that if( eNetworkEvent == eNetworkUp ) it call again to the vStartSimpleMQTTDemo, isn’t it?

void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
{
/* If the network has just come up…*/
if( eNetworkEvent == eNetworkUp )
{
uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
char cBuffer[ 16 ];

	vStartSimpleMQTTDemo();

.
.
.

Normally you would guard against that happening, as per https://github.com/FreeRTOS/Lab-Project-coreMQTT-Agent/blob/main/source/main.c#L158