Websocket goes to sleep after a while

websocket goes to sleep after a while. I listen to the transfer events of a contract and send a message to telegram. but after a while it starts not being able to catch the events.

const Web3 = require("Web3")
var web3;
const abi = require('./abi.json') 
const express = require('express');

const TelegramBot = require('node-telegram-bot-api');

const app = express();
const port = 3002;
var bodyParser = require('body-parser');
var cors = require('cors')
app.use(cors())
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
const provider = new Web3.providers.WebsocketProvider("WEB_SOCKET_URL_FROM_SPEEDY_NODES")
web3 = new Web3(provider);
contract = new web3.eth.Contract(abi, "CONTRACT_ADDRESS");
  
    contract.events.Transfer({}).on("data", (data) => {
          try {
            //const bot = new TelegramBot(token, { polling: true });
                try {
                    // bot send message
                } catch (error) {
                    console.log(error);
                }    

           } catch (err) {

                console.error(err)
           }
    })


app.listen(port);
module.exports = app

we recommend to use event sync on a server:
https://docs.moralis.io/moralis-dapp/automatic-transaction-sync/smart-contract-events

with web sockets, they may disconnect from time to time
you can also try another node provider if you want to use websockets