Username - password with RabbitMq not working

1,418 views
Skip to first unread message

Tim Geerts

unread,
Apr 15, 2013, 9:10:23 AM4/15/13
to masstrans...@googlegroups.com
Hi

I have removed the guest user from my rabbitmq service broker and added a new user with administrator permissions.

I have following code:

            var bus = ServiceBusFactory.New((config) =>
                {
                    //config.UseRabbitMq();
                    config.UseRabbitMqRouting();
                    config.ReceiveFrom("rabbitmq://myuser:mypass@localhost/userPassQueue");
                });
 
            Message msg = new Message() { MyProperty = "Bronstige neusaap" };
 
            bus.Publish(msg);

The queue get's created properly in the rabbitmq service broker, but when publishing the message it goes wrong.

MassTransit also creates a queue(?) for the messagetype but then it uses guest/guest and not my credentials anymore. Did I do something wrong?

Thanks for helping.

Greets
Tim

Tim Geerts

unread,
Apr 15, 2013, 9:28:48 AM4/15/13
to masstrans...@googlegroups.com
ExceptionMessage:

MassTransit.Exceptions.PublishException was unhandled
  Message=At least one exception occurred publishing MTWithUserPass.Message to rabbitmq://localhost/MTWithUserPass:Message
  Source=MassTransit
  StackTrace:
       at MassTransit.ServiceBus.Publish[T](T message, Action`1 contextCallback) in d:\BuildAgent-03\work\19b3d91f8acfae7a\src\MassTransit\ServiceBus.cs:line 207
       at MassTransit.ServiceBus.Publish[T](T message) in d:\BuildAgent-03\work\19b3d91f8acfae7a\src\MassTransit\ServiceBus.cs:line 156
       at MTWithUserPass.Program.Main(String[] args) in C:\Users\tim\Documents\Visual Studio 2010\Projects\Masstransit\MTWithUserPass\MTWithUserPass\Program.cs:line 23
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: MassTransit.Exceptions.SendException
       Message=rabbitmq://localhost/MTWithUserPass:Message => An exception was thrown during Send
       Source=MassTransit
       StackTrace:
            at MassTransit.Transports.Endpoint.Send[T](ISendContext`1 context) in d:\BuildAgent-03\work\19b3d91f8acfae7a\src\MassTransit\Transports\Endpoint.cs:line 111
            at MassTransit.Pipeline.Sinks.EndpointMessageSink`1.<Enumerate>b__0(IBusPublishContext`1 x) in d:\BuildAgent-03\work\19b3d91f8acfae7a\src\MassTransit\Pipeline\Sinks\EndpointMessageSink.cs:line 45
            at MassTransit.Pipeline.Sinks.OutboundConvertMessageSink`1.<>c__DisplayClass2.<>c__DisplayClass4.<Enumerate>b__1(ISendContext x) in d:\BuildAgent-03\work\19b3d91f8acfae7a\src\MassTransit\Pipeline\Sinks\OutboundConvertMessageSink.cs:line 36
            at MassTransit.ServiceBus.Publish[T](T message, Action`1 contextCallback) in d:\BuildAgent-03\work\19b3d91f8acfae7a\src\MassTransit\ServiceBus.cs:line 180
       InnerException: RabbitMQ.Client.Exceptions.BrokerUnreachableException
            Message=None of the specified endpoints were reachable
            Source=RabbitMQ.Client
            StackTrace:
                 at RabbitMQ.Client.ConnectionFactory.CreateConnection(Int32 maxRedirects)
                 at RabbitMQ.Client.ConnectionFactory.CreateConnection()
                 at MassTransit.Transports.RabbitMq.RabbitMqConnection.Connect() in d:\BuildAgent-03\work\19b3d91f8acfae7a\src\Transports\MassTransit.Transports.RabbitMq\RabbitMqConnection.cs:line 48
                 at MassTransit.Transports.ConnectionHandlerImpl`1.Connect() in d:\BuildAgent-03\work\19b3d91f8acfae7a\src\MassTransit\Transports\ConnectionHandlerImpl.cs:line 48
                 at MassTransit.Transports.ConnectOnFirstUsePolicy.Execute(Action callback) in d:\BuildAgent-03\work\19b3d91f8acfae7a\src\MassTransit\Transports\ConnectOnFirstUsePolicy.cs:line 31
                 at MassTransit.Transports.ConnectionPolicyChainImpl.Next(Action callback) in d:\BuildAgent-03\work\19b3d91f8acfae7a\src\MassTransit\Transports\ConnectionPolicyChainImpl.cs:line 49
                 at MassTransit.Transports.ConnectionPolicyChainImpl.Execute(Action callback) in d:\BuildAgent-03\work\19b3d91f8acfae7a\src\MassTransit\Transports\ConnectionPolicyChainImpl.cs:line 54
                 at MassTransit.Transports.ConnectionHandlerImpl`1.Use(Action`1 callback) in d:\BuildAgent-03\work\19b3d91f8acfae7a\src\MassTransit\Transports\ConnectionHandlerImpl.cs:line 87
                 at MassTransit.Transports.RabbitMq.OutboundRabbitMqTransport.Send(ISendContext context) in d:\BuildAgent-03\work\19b3d91f8acfae7a\src\Transports\MassTransit.Transports.RabbitMq\OutboundRabbitMqTransport.cs:line 49
                 at MassTransit.Transports.Transport.Send(ISendContext context) in d:\BuildAgent-03\work\19b3d91f8acfae7a\src\MassTransit\Transports\Transport.cs:line 51
                 at MassTransit.Transports.Endpoint.Send[T](ISendContext`1 context) in d:\BuildAgent-03\work\19b3d91f8acfae7a\src\MassTransit\Transports\Endpoint.cs:line 105
            InnerException: RabbitMQ.Client.Exceptions.PossibleAuthenticationFailureException
                 Message=Possibly caused by authentication failure
                 Source=RabbitMQ.Client
                 StackTrace:
                      at RabbitMQ.Client.Impl.ConnectionBase.StartAndTune()
                      at RabbitMQ.Client.Framing.Impl.v0_9_1.Connection.Open(Boolean insist)
                      at RabbitMQ.Client.Impl.ConnectionBase..ctor(ConnectionFactory factory, Boolean insist, IFrameHandler frameHandler)
                      at RabbitMQ.Client.Framing.Impl.v0_9_1.Connection..ctor(ConnectionFactory factory, Boolean insist, IFrameHandler frameHandler)
                      at RabbitMQ.Client.Framing.Impl.v0_9_1.ProtocolBase.CreateConnection(ConnectionFactory factory, Boolean insist, IFrameHandler frameHandler)
                      at RabbitMQ.Client.ConnectionFactory.FollowRedirectChain(Int32 maxRedirects, IDictionary connectionAttempts, IDictionary connectionErrors, AmqpTcpEndpoint[]& mostRecentKnownHosts, AmqpTcpEndpoint endpoint)
                 InnerException: RabbitMQ.Client.Exceptions.OperationInterruptedException
                      Message=The AMQP operation was interrupted: AMQP close-reason, initiated by Library, code=541, text="Unexpected Exception", classId=0, methodId=0, cause=System.IO.IOException: Unable to read data from the transport connection: De externe host heeft een verbinding verbroken. ---> System.Net.Sockets.SocketException: De externe host heeft een verbinding verbroken
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at RabbitMQ.Client.Impl.Frame.ReadFrom(NetworkBinaryReader reader)
   at RabbitMQ.Client.Impl.SocketFrameHandler_0_9.ReadFrame()
   at RabbitMQ.Client.Impl.ConnectionBase.MainLoopIteration()
   at RabbitMQ.Client.Impl.ConnectionBase.MainLoop()
                      Source=RabbitMQ.Client
                      StackTrace:
                           at RabbitMQ.Client.Impl.SimpleBlockingRpcContinuation.GetReply()
                           at RabbitMQ.Client.Impl.ModelBase.ConnectionStartOk(IDictionary clientProperties, String mechanism, Byte[] response, String locale)
                           at RabbitMQ.Client.Impl.ConnectionBase.StartAndTune()
                      InnerException: 

Tim Geerts

unread,
Apr 15, 2013, 10:00:32 AM4/15/13
to masstrans...@googlegroups.com
Found it using the, nowhere documented, ConfigureHost:

                    config.UseRabbitMq(r => 
                    {
                        r.ConfigureHost(new Uri("rabbitmq://myuser:mypass@localhost/userPassQueue"), h =>
                        {
                            h.SetUsername("myuser");
                            h.SetPassword("mypass");
                        });
                    });

Chris Patterson

unread,
Apr 15, 2013, 10:41:38 AM4/15/13
to masstrans...@googlegroups.com
Yes, I need to update the documentation on this. This was part of the fix to get username/password out of the URI so that it isn't written to the message headers. 


--
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/msg/masstransit-discuss/-/l3tzHHVc3nMJ.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

David Glassborow

unread,
Apr 30, 2013, 7:00:54 AM4/30/13
to masstrans...@googlegroups.com
It is also worth knowing that if your user is using a different vhost, you need to specify that on the url between the server name and the unique bus name:

                    config.UseRabbitMq(r => 
                    {
                        r.ConfigureHost(new Uri("rabbitmq://myuser:mypass@localhost/userVhost/userPassQueue"), h =>
                        {
                            h.SetUsername("myuser");
                            h.SetPassword("mypass");
                        });
                    });

VHosts are useful for having more than one instance of your system on the same RabbitMQ server (e.g. development and testing).

Chris Patterson

unread,
Apr 30, 2013, 10:58:19 PM4/30/13
to masstrans...@googlegroups.com
Yes, credentials are configured per VHOST, so you need to configure each host/vhost separately.


--
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.

João Lourenço

unread,
Jun 19, 2013, 9:03:42 AM6/19/13
to masstrans...@googlegroups.com
So you need to specify the credentials twice?

Brad Wilson

unread,
Jun 19, 2013, 11:21:10 AM6/19/13
to masstrans...@googlegroups.com
No. It's not needed in the Uri in that case.

--
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.

Chris Patterson

unread,
Jun 19, 2013, 11:38:19 AM6/19/13
to masstrans...@googlegroups.com
Brad is right, you just need:

config.UseRabbitMq(r => 
                    {
                        r.ConfigureHost(new Uri("rabbitmq://localhost/userPassQueue"), h =>
                        {
                            h.SetUsername("myuser");
                            h.SetPassword("mypass");
                        });
                    });


On Wed, Jun 19, 2013 at 6:03 AM, João Lourenço <blacks...@gmail.com> wrote:
--
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.

João Lourenço

unread,
Jun 19, 2013, 11:55:03 AM6/19/13
to masstrans...@googlegroups.com
Ah ok, tried that and it works perfectly. Thanks for the quick responses!

Shane

unread,
Dec 13, 2013, 5:00:13 PM12/13/13
to masstrans...@googlegroups.com
If I use the configure host I still have to set ReceiveFrom.  Is that normal?  Does that mean that ConfigureHost only has to point to the root and ReceiveFrom will be the specific queue I want?

var bus = ServiceBusFactory.New(sbc =>
            {
                sbc.UseRabbitMq(r =>
                {
                    r.ConfigureHost(new Uri("rabbitmq://localhost/" + queue), h =>
                    {
                        h.SetUsername("myuser");
                        h.SetPassword("mypass");
                    });
                });
                sbc.ReceiveFrom("rabbitmq://10.8.23.166/" + queue);
                sbc.Subscribe(subs =>
                    subs.Consumer<TextMessageConsumer>().Permanent());
            });

removing sbc.ReceiveFrom(...) throws a Configuration Exception that the Input Address is null.


On Wednesday, June 19, 2013 11:38:19 AM UTC-4, Chris Patterson wrote:
Brad is right, you just need:

config.UseRabbitMq(r => 
                    {
                        r.ConfigureHost(new Uri("rabbitmq://localhost/userPassQueue"), h =>
                        {
                            h.SetUsername("myuser");
                            h.SetPassword("mypass");
                        });
                    });
On Wed, Jun 19, 2013 at 6:03 AM, João Lourenço <blacks...@gmail.com> wrote:
So you need to specify the credentials twice?


On Monday, 15 April 2013 16:00:32 UTC+2, Tim Geerts wrote:
Found it using the, nowhere documented, ConfigureHost:

                    config.UseRabbitMq(r => 
                    {
                        r.ConfigureHost(new Uri("rabbitmq://myuser:mypass@localhost/userPassQueue"), h =>
                        {
                            h.SetUsername("myuser");
                            h.SetPassword("mypass");
                        });
                    });

--
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-discuss+unsub...@googlegroups.com.

To post to this group, send email to masstrans...@googlegroups.com.

Chris Patterson

unread,
Dec 13, 2013, 7:09:45 PM12/13/13
to masstrans...@googlegroups.com
They need to be the same address, IE, localhost in both configureHost and receiveFrom -- as the matching is done by hostname as a string.


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.

Shane

unread,
Dec 16, 2013, 3:37:32 PM12/16/13
to masstrans...@googlegroups.com
That was a copy paste error.  The intent was they are the same.  The question was actually that it seemed weird that you need both the URI in ConfigureHost and ReceiveFrom and why you need the URI in both places?
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsubscribe...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

--
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-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

Travis Smith

unread,
Dec 18, 2013, 7:10:39 PM12/18/13
to masstrans...@googlegroups.com
You really only need the RecieveFrom. 

-Travis


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.

Dru Sellers

unread,
Dec 19, 2013, 10:50:30 AM12/19/13
to masstrans...@googlegroups.com
Actually with RabbitMQ depending on how the server is set up you may need both. Chris gave me a reason (which I have since forgotten) but its something I would VERY much like to clean up.

-d


Reply all
Reply to author
Forward
0 new messages