Internal pinging is where the application, keeps itself alive usually at a certain interval, to stop them from sleeping. This is used to stop apps sleeping in free hosting services, which can allow for 24/7 hosting, given the right conditions.
Works on Heroku.com - (until free dyno hours run out)
Works on Glitch.com (10 hours at a time)
This package is used to send HTTP GET requests to a URL. You can use the package of your choice.
$ npm i -S node-fetch
This script will send a HTTP GET request to a Heroku app, every 5 minutes. In theory, this will keep it awake until the free dyno hours run out.
keep-alive.jsconst fetch = require('node-fetch');setInterval(() => fetch(`https://<your_app>.herokuapp.com`), 5 * 60 * 1000);
keep-alive.tsimport fetch from 'node-fetch';setInterval(() => fetch(`https://<your_app>.herokuapp.com`), 5 * 60 * 1000);
Make sure to connect the script to the bottom of your main file (e.g.
app.js), and it should do the rest.
Your application should stay online for longer, or 24/7, depending on your host.
Unlike internal pinging, external pinging sends requests from the outside - from another application. For example, connecting to 2pg.xyz, from the browser, would count as an external ping. Doing this from the browser would keep a Heroku application alive, as it would prevent it from auto sleeping.
Below is an entire repository dedicated to this concept. It also works with multiple URLs, and logs when an app is kept alive.