Keep alive on shared server

Hi, I’m new to HangFire. I set it up and it’s working fine, but I have another issue. I hosted it on a shared server (school project) so I don’t exactly have access to IIS and can’t configure it to keep this alive. I’ve read that if you simply ping it regularly you can keep it alive. But it doesn’t, for some reason. So, is there any way to keep it alive using code or something, without having to resort to IIS?

It’s not a literal “ping” in the TCP/IP sense. For this purpose, “ping” means to have a little program request a web page from IIS on a regular basis. Doing this means IIS will continue to see your site as being busy (not idle) and therefore not shut it down after a period of inactivity.

What sort of PC or device do you have available to run the ping from?

Hi, I forgot to mention I used a service to do that. In this case, uptimerobot. I tried pings, http requests… I have messaged them at uptimerobot and I’ve been told that some setups are not kept alive by head requests. And they suggested I tried keyword monitoring, which sends GET requests. I haven’t tried it yet but when I do I’ll update you.

You could try to execute your hangfire server within a Windows Service. This shouldn’t be affected by IIS in that case.

Hi. That wasn’t required, fortunately. I saw your comment yesterday but I wanted to make sure of what I was saying.

And it seems that using uptimerobot’s keyword request work great. I have recurring tasks that need to be done every 2 hours and it’s alive since yesterday., so yes, apparently it works.

As stated by them at uptimerobot: “Some setups are not kept alive with HEAD requests. Yet, keyword monitoring sends GET requests and you can give it a try with keyword monitors.”.

This followed after I asked them about the ping and HTTP requests, which were supposed to work but they didn’t.

So, that’s that. If anyone needs to have a windows simulated service they must definitely try one of these requests.

Although, I want to thank you all who tried to help. Big thanks. :slight_smile:

Even more simply, schedule a job that hits your web application every few minutes. No external service required.

Sure, but I’d be back to square one. How would I keep that job active? I have to use a shared server and in a shared server I can’t access the IIS. I could have a computer do that with a windows scheduled task, but I can’t have it on 24/7.

If this was a big company project sure the company would provide that stuff. But that’s not the case.

No, that totally works. A job that does nothing but use httpclient to get your web page. I’m on mobile or I’d post an example. But just schedule job minutely, to retrieve your page. You’re not doing anything with IIS specifically, but just keeping your app domain from being unloaded

Hm… So, you mean, in the same web page have both my current task and an http task? And how would I do that? I haven’t yet used httpclient before.

Late reply, but if you do something like this:

    public static class Pinger
    {
        static void Setitup()
        {
            RecurringJob.AddOrUpdate(() =>  Pinger.Ping("http://mysite.com"), Cron.MinuteInterval(5));
        }
        static HttpClient client = new HttpClient();
        public static void Ping(string  url)
        {
            client.GetAsync(url);
        }
    }

In your web applications startup, just call Pinger.Setitup() . That job will fire every 5 minutes, and if your web application doesn’t shut down in less time that 5 minutes, your web app, and the background job servers within it will not be unloaded from the host.

Hey, nice answer. I don’t need it anymore as I ended up using a monitor to search for a keyword. And it worked nicely. But next time I’ll give it a try on this one. Thanks. :slight_smile: