Hangfire - Unable to resolve services [Answered]
Working with Hangfire. I have a plugin service which has an InitializeAsync method that looks like this:
I request and dump those services as a test to make sure that all of them are there, even though I've independently verified by examining the service collection as it's being built. All of them pass. However, when Hangfire tries to request them, it's unable to resolve some service. I cannot see which one though because the exception appears to be swallowed. I do get this exception though:
It's failing to initialize the ReportBuilderPlugin, an error which is returned when
InitializeAsync()
throws or returns an unsuccessful result.21 Replies
I am using this scoped job activator with Hangfire and I have confirmed that it actually uses it by stepping through.
I don't see anything hangfire related in the stack trace?
So I feel like it's hangfire because my InitializeAsync method returns a successful result. It's only after hangfire starts executing its jobs that I run into any issues. But that's just an educated guess since the stack trace appears to be truncated, like something's being caught and a new exception is being thrown without the old one added as an inner
So if you never add those hangfire jobs what happens
Also, what do you see in the hangfire dashboard?
I don't have a hangfire dashboard because this is a console app
Also the jobs are stored in the database so I'd have to remove explicitly remove them, but I can give it a try
Does the plugin actually do a REST request?
This one does not, not anymore.
Only my other plugin does REST requests.
That's what the stack trace says though
It doesn't say a service couldn't be resolved
Just that it failed because of a REST request
The report builder plugin relies on the data plugin
Whatever is failing it seems to be something that is executing and failing, not a missing service
Hrm... strange that it would say it's an init error then
@Jax Any ideas why this would show up that way?
(This is Jax's plugin system)
Because it failed to initialize because the REST request didn't work
Hoping that this will at least tell me where to look
So figure out what REST request it's trying to do
And see why it's failing
Maybe it's using some wrong configuration settings or something
At this stage the only rest request it should be making is that to authenticate
So hopefully that's the one that's erroring
You can also use fiddler to see what's going on
Aay, that was it
Easy enough
I think what I need to do is change the error registration type.
I'll need to confer with Jax on what to use there though
Thanks for helping me track that down
I'll close this issue and ask in his server I think, since this bit has been resolved
✅ This post has been marked as answered!