Hi there,
I've got a WebApi2 application using MassTransit 3.0.11-beta with RabbitMq, and some hosting constraints for production applications, that leads me to use IIS to host this application.
The problem being, when I publish a message to the previously-mentioned, it instantly reboots and the following error appears in the EventViewer:
=====================
Exception: System.NullReferenceException
Message: Object reference not set to the instance of an object.
StackTrace: at System.Web.ThreadContext.AssociateWithCurrentThread(Boolean setImpersonationContext)
at System.Web.HttpApplication.OnThreadEnterPrivate(Boolean setImpersonationContext)
at System.Web.LegacyAspNetSynchronizationContext.CallCallbackPossiblyUnderLock(SendOrPostCallback callback, Object state)
at System.Web.LegacyAspNetSynchronizationContext.CallCallback(SendOrPostCallback callback, Object state)
at System.Threading.Tasks.AwaitTaskContinuation.RunCallback(ContextCallback callback, Object state, Task& currentTask)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.Tasks.AwaitTaskContinuation.<ThrowAsyncIfNecessary>b__1(Object s)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
===================================
The thing being, when I launch the application using self-hosting (Katana), everything works fine.
Here is the configuration for my service:
var busControl = Bus.Factory.CreateUsingRabbitMq(sbc =>
{
sbc.UseNLog();
sbc.UseJsonSerializer();
var uri = new Uri(string.Format("rabbitmq://{0}/{1}", _configuration.Host, _configuration.VirtualHost));
var host = sbc.Host(uri, h =>
{
h.Username(_configuration.Username);
h.Password(_configuration.Password);
});
sbc.ReceiveEndpoint(host, _configuration.QueueName, ep =>
{
ep.UseConcurrencyLimit(1);
ep.PrefetchCount = 1;
ep.LoadFrom(_container);
});
});
_busHandle = busControl.Start();
_container.RegisterInstance<IBus>(busControl);
MassTransit starts correctly, and manages to connect to my local instance of RabbitMq, but the application crashes as soon as it receives a message.
Do you have any idea on what could be happening here?
Thanks!