The details abou the error are as below:
When an SNMP agent restarts, it's engineBoots value gets incremented. But the manager application's engineBoots and engineTime values remain unchanged.
engineBoots: The number of times the SNMP engine has (re-)initialized itself since snmpEngineID was last configured.
engineTime: The number of seconds since the value of the snmpEngineBoots object last changed.
Now, when the manager sends the next SNMP request, the engineBoots in the request will not be equal to the engineBoots value of the agent and the agent responds with an "usmStatsNotInTimeWindows" error.
To synchronize between the agent and the manager, there should be some mechanism that informs the manager that the agent has restarted, so that it will update its values.
This may acts as a trap sent by the agent to the manager at the time of restarting. If there is no such mechanism, then the very first GET request sent to that agent (after the restart) will fail and following requests would succeed.
The SnmpAPI class contains handles to SnmpEngineTable and USMUserTable. When a SNMPv3 response message is received at the SnmpSession's receiver thread, the locally stored values of the engineTime and engineBoots is updated internally, given timeliness check of the received message is successful.
SNMP API automatically updates the engineTime and engineBoots once it receives a PDU with a "usmStatsNotInTimeWindows" error.