Sleep time ? Using CronJob Bot stops answering after ~ 28mins


#1

Hello,
So I read some informations about the sleep-time that is around 5mins (I experienced it before reading it in fact as my bot lost stored informations, but that is ok now).

My bot is a FaceBook Messenger Bot. He stores some data in a Database.

I would like to send a mail every week, with the detail of the Data stored. I use CronJob for that.
But it seems my Bot fall asleep after 28mins. ( I created a test where every 4mins he sends me a message on Facebook, he stopped answering after 7 messages ). I saw on a closely-similar post that someone proposed to ping the app. But I don’t think it was the glitch app. In fact I don’t see how to ping my Bot in glitch. Isn’t weird to auto-ping an app ? Is it possible to do so ? So my Bot will stay awake all time ?

I hope I’ve been clear enough, thanks.


#2

If you use your CronJob service to hit an end-point that you expose in your app, it will wake it and perform the action necessary. If that’s stopping after several pings, then it’s likely this isn’t setup correctly. Feel free to share your app so we can take a look.


#3

Thanks for the fast answer.
I think I just hit the endpoint once.
I send a message to my bot, then I don’t send others. He justs keep sending to me. And then stop.
Because no end-point are hitted after that.

So I should “auto-ping” my bot ?

For example, when it answers me, I also make it hit its end-point ?

EDIT : Can I send a Send request to the url/webhook of my app ? Whatever the data in it ?


#4

Yeah, so your project will have gone to sleep again after 5 minutes of hitting that end-point once. I’m surprised it got as far as 28 mins - the responses probably kept it awake. But the end-point you hit with the cron job can do anything, it’s just needed to wake it, so it doesn’t have to hit the end-point as part of the reply.


#5

So as to ping it, I added the ping package, and I ping my app url.
The ping answer seemed to be ok.

Let’s see what it gives in 20-30mins or more :slight_smile:


#6

Mhhh, the ping give the answer : “host is live” but the bot still sleep after 20mins, when I ping the url of my project ( ProjectName.me/ )
When I try to ping the ProjectName.me/webhook it says it’s dead :confused:

A ping is enough to normaly keep the app alive ?


#7

A true ping won’t get routed to your container, so it won’t help - you’re just pinging other code on glitch.me that way. You need to make a web request to your server every once in a while instead.


#8

Ok, that what I was thinking about…
A Post request may do it ? Or I am totally wrong ?


#9

Yes, any HTTP request should work.


#10

This should work for you… https://www.npmjs.com/package/glitchup Don’t go using it on all your projects if it’s not needed though. :wink:


#11

Ahaha nice ad for you :stuck_out_tongue:
But thank you, I’ll try to insert that in my project ( Don’t worry I have only 1 project so I won’t abuse it ! ).


#12

Well, thank you for all your answers and your time.
I think it’s working as I wished :slight_smile:

I used Shindakun’s package.