Getting error while interacting to blockchain to fetch events

I am trying to fetch events from blocks and sometime getting this error –
Error: PollingBlockTracker - encountered an error while attempting to update latest block:
at Timeout._onTimeout

Emitted ‘error’ event on Web3ProviderEngine instance at:
at safeApply
please help me with solution and explaination why this error occured?

update to above error after i got solution…
cause for error - As for testnet we are using public rpc url to connect to polygon network. So, sometime due to heavy load it won’t respond.
earlier i was using -
now i am using –
you can use any one of them if one is not working – or or

if error still persists -
You can sign up for a dedicated free RPC URL at the following:

  • Moralis
  • Infura