IIS-hosted application crashes when consuming a message

1,053 views
Skip to first unread message

Thibault Voisin

unread,
Nov 30, 2015, 12:14:42 PM11/30/15
to masstransit-discuss
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!

Chris Patterson

unread,
Nov 30, 2015, 2:02:38 PM11/30/15
to masstrans...@googlegroups.com
I'm not sure what could be happening, trust level issue with the IIS host?

Also, upgrade to .15 - it's been generally released for quite some time now! :)


--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/d4229b21-3635-4628-be55-09b19e722878%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Wayne Brantley

unread,
Nov 30, 2015, 6:05:44 PM11/30/15
to masstransit-discuss
Version 15 works pretty well.  Worth an upgrade to see if it fixes your issue above.
The issue looks to be around the synchronization context and I know there were lots of fixes for async (adding configureawait(false) everywhere) that could cause this.

If it does not fix it - does this all work fine if hosted as just a regular service with topshelf?


To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.

Thibault Voisin

unread,
Dec 1, 2015, 8:31:27 AM12/1/15
to masstransit-discuss
Thanks for the quick answer : it seems switching to version 15 fixes the problem, indeed. I'll do some additional testing, but it seems to work fine for now.

Thanks again!
Reply all
Reply to author
Forward
0 new messages