Hangfire dashboard gets stuck enqueueing jobs from list

Hi there.

Just started using hangfire. All looks good apart from on the dashboard when I click ‘Enqueue Jobs’

The dashboard seems to go into the Enqueueing state but then never Enqueues anything.

If I open an individual job and Click Re-Enqueue it gets added fine.

Cant see anyone else talking about this, so it must be something I am doing wrong :wink:

I have the same issue. I am trying to use Hangfire with Autofac in an ASP.NET MVC application.
I have also included ElmahLogProvider to log if any errors are encountered, but I don’t see any error out there.

The method gets enqueued in background job and never gets executed.

This issue may be caused by the following reasons that were fixed in Hangfire 1.4.4:

  1. InvalidCastException in Dashboard when using Microsoft.Owin 3.0.1 package.
  2. One of middleware components in your project reads the request body without rewinding it back to the beginning.

I am still having the issue on 1.4.4 in a Windows Service. It appears that all Web API requests are failing with error 500. However it appears that it is working fine in our ASP.NET application.

Any thoughts?

@Darren_Maddox, one of middleware components in your project is likely to read the body stream (using ReadFormAsync or directly the Request.Body stream), but does not buffer it into MemoryStream, making it seekable.

500 error contains the details, I’m sure it is Can’t read the request body: stream is not at the beginning position and is not seekable.. This error message says that someone else already read the body stream, and Hangfire can’t do anything – it can’t read it, because current position is at the end, and it can’t seek it, because it is not buffered.

There are some middleware components (this or this, I’ve seen others) that read the body, however they replace the body stream with buffered versions and rewind the stream back to the beginning.

Please ensure your middleware is not egoist and allow others to access the body.

The 500 response is empty.

I threw together a quick console app with nothing but Hangfire & OWIN.

Program.cs

    static void Main(string[] args)
    {
        GlobalConfiguration.Configuration.UseSqlServerStorage(@"<Connection String Here>");
        var wa = WebApp.Start<Startup>(url: "http://localhost:9005");
        RecurringJob.AddOrUpdate(() => Console.WriteLine("Ping"), Cron.Minutely);
        Console.ReadLine();
        wa.Dispose();
    }

StartUp.cs

    public void Configuration(IAppBuilder app)
    {
        // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
        app.UseHangfireDashboard();
        app.UseHangfireServer();
    }

It still seems to have the same issue. The dashboard loads but Web API requests fail. If I’m doing something dumb let me know :slight_smile:

It works after downgrading to 1.4.3

Thanks for this post! I’ve added UseErrorPage method…

app.UseErrorPage();
app.UseHangfireDashboard();
app.UseHangfireServer();

… and found NotSupportException “This stream does not support seek operations.”, a bug in 1.4.4. I’ve just released 1.4.5 with hotfix for this problem, however it is totally unrelated yto your previous one.

Are you using Web Api? Here is a similar problem on SO.

Can confirm the issue is resolved!

Smashing thanks for all your help!

I think I have confused you some what. I have two applications using Hangfire, an ASP.NET one which has always been working and showed no symptoms and a new service application which had the issue which you have now resolved.

Thanks for your help have a good one!

Ok, good to hear, thank you for reporting a bug!