1

We are using MassTransit in combination with RabbitMQ. Following dll versions are being used in our Console Application:

  • MassTransit
    • Runtime version v4.0.30319 - Version 3.4.0.0
  • MassTransit.RabbitMqTransport
    • Runtime version v4.0.30319 - Version 3.4.0.0
  • RabbitMQ.Client
    • Runtime version v4.0.30319 - Version 4.0.0.0
  • NewId
  • ...

Sometimes a publish causes a crash even if the Publish method is wrapped in a try/catch. And I have to say we are doing 2000+ publishes in a row.

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at RabbitMQ.Client.Framing.Impl.Connection.HeartbeatReadTimerCallback(Object state)
   at System.Threading.TimerQueueTimer.CallCallbackInContext(Object state)
   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.TimerQueueTimer.CallCallback()
   at System.Threading.TimerQueueTimer.Fire()
   at System.Threading.TimerQueue.FireNextTimers()
   at System.Threading.TimerQueue.AppDomainTimerCallback()

The Publish which is causing the NullReference is:

    ...
    IBusControl BusControl = Bus.Factory.CreateUsingRabbitMq(busFactoryConfig =>
    {
        busFactoryConfig.Host(new Uri(ServerUrl), hostConfig =>
        {
            hostConfig.Username(Username);
            hostConfig.Password(Password);
        });
    });
    ...
    //I suppose the crash occurs after the code below is executed
    TaskUtil.Await(() => BusControl.Publish(message));

I know about this issue but I don't see any clear solution for the problem even it is closed...

I want to ask, if updating the dlls is the solution, to which version do we have to update and do we have to update MassTransit dlls only (see listing above) or the RabbitMQ server also? I appreciate any help.

EDIT This is an issue occurring on our production environment. So not possible for me to debug unfortunately...

EDIT Got answer from someone on Gitter.im

I suggest you update MT to the latest version. It uses the 4.1.3 version of rabbitmq. This one should contain the fix. In case of your problem being related to the rabbitmq issue you just posted. In other cases I can't really help you. And by latest version I mean https://www.nuget.org/packages/MassTransit.RabbitMQ/3.5.7

Ozkan
  • 3,880
  • 9
  • 47
  • 78
  • Possible duplicate of [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – ProgrammingLlama Dec 12 '17 at 10:39
  • It has everything to do with your question. If it's a bug in their library you have two options: a) debug it as described in the duplicate - it is open source, or b) report it to them! [SO] is _not_ the place to report bugs in software libraries that you use. – ProgrammingLlama Dec 12 '17 at 10:44
  • Look [here](http://masstransit-project.com/) in the Help me section. They refer to Stackoverflow... – Ozkan Dec 12 '17 at 10:47
  • Please show me the place where they state "if there is a bug within our code, seek help for it on [SO]." They don't. They have a dedicated "[Report a bug](https://github.com/MassTransit/MassTransit#github-issues)" link on the same page. – ProgrammingLlama Dec 12 '17 at 10:49
  • 2
    I'm asking a question, I don't know it this is a bug! Stop making things difficult – Ozkan Dec 12 '17 at 10:50
  • It probably isn´t a real bug, but just a parameter being null and not checked in the lib. However as stated in the possible duplicate, you should definitly try to debug the issue, it´s impossible for us to guess what is `null` in your case. – MakePeaceGreatAgain Dec 12 '17 at 10:52
  • Look, if it's something you're doing wrong, your question _is_ a duplicate of the one I linked to. Debug your code, find the error. Even add conditions to break on null (i.e. `if (a == null) { System.Diagnostics.Debugger.Break(); }`). If it isn't in your code, and it's a bug with the library, report it to them. Either way, I suspect you would be much better equipped to find the bug if you also debugged through their code, too. – ProgrammingLlama Dec 12 '17 at 10:54
  • Oh God, this is an issue occurring on our production environment. So not possible for me to debug unfortunately... – Ozkan Dec 12 '17 at 10:55
  • 1
    Hmm, in that case I'd suggest removing the reference to RabbitMQ from your project and then add the RabbitMQ project to your solution, and reference it as a project. Perhaps then you might get a more useful error message. You could also read through the RabbitMQ code to see if there's anything you're missing within the objects you pass in. – ProgrammingLlama Dec 12 '17 at 11:01
  • 1
    Any null reference exception can be considered a bug, so indeed the best way is to post issue at that library issue tracker (if there is such). Before of course you need to check if there is such issue already, and if it is not resolved in more recent version. – Evk Dec 12 '17 at 11:04

0 Answers0