Web3/Infura stops reacting to events after some time

I am listening to events a smart contract emits via

const CONTRACT= new web3.eth.Contract(

listener = CONTRACT.events.MyEvent();

liquidityLockListener.on("data", async (event) => {
  // do things

but i have noticed the listener stops listening to emitted events after some time. No error being emitted whatsoever, it just stops doing its thing.
any idea?
the events I am listening to are usually very slow, few hours between them. Is there a possibility that web3 maybe just silently times out or something? Again, I am not getting any error messages, it just doesnt do anything anymore.
I receive the first events after I start up the script perfectly fine but after some time it just stops

Hi @Trivo, and welcome to the Infura community!

Yes, there is typically a timeout over HTTP connections with web3. One option is to connect via WebSocket instead of HTTP, or you can usually override the timeout. For web3js, there are a few different options to override their timeouts listed here in their docs.

hello i have the same problem with wss

const myContract = new web3Ws.eth.Contract(abi.abi, process.env.STAKING_CONTRACT);
const subscription = myContract.events.Transfer();
subscription.on(‘data’, event => {

its working for 24 hours and after that sundently stops emitting the event :frowning_face: