• <i id='mBrTB'><tr id='mBrTB'><dt id='mBrTB'><q id='mBrTB'><span id='mBrTB'><b id='mBrTB'><form id='mBrTB'><ins id='mBrTB'></ins><ul id='mBrTB'></ul><sub id='mBrTB'></sub></form><legend id='mBrTB'></legend><bdo id='mBrTB'><pre id='mBrTB'><center id='mBrTB'></center></pre></bdo></b><th id='mBrTB'></th></span></q></dt></tr></i><div id='mBrTB'><tfoot id='mBrTB'></tfoot><dl id='mBrTB'><fieldset id='mBrTB'></fieldset></dl></div>

        <legend id='mBrTB'><style id='mBrTB'><dir id='mBrTB'><q id='mBrTB'></q></dir></style></legend>
          <bdo id='mBrTB'></bdo><ul id='mBrTB'></ul>
        <tfoot id='mBrTB'></tfoot>
      1. <small id='mBrTB'></small><noframes id='mBrTB'>

        使用用户名和密码时 RabbitMQ C# 连接问题

        时间:2023-08-24

        <i id='O2xly'><tr id='O2xly'><dt id='O2xly'><q id='O2xly'><span id='O2xly'><b id='O2xly'><form id='O2xly'><ins id='O2xly'></ins><ul id='O2xly'></ul><sub id='O2xly'></sub></form><legend id='O2xly'></legend><bdo id='O2xly'><pre id='O2xly'><center id='O2xly'></center></pre></bdo></b><th id='O2xly'></th></span></q></dt></tr></i><div id='O2xly'><tfoot id='O2xly'></tfoot><dl id='O2xly'><fieldset id='O2xly'></fieldset></dl></div>

            <small id='O2xly'></small><noframes id='O2xly'>

              <bdo id='O2xly'></bdo><ul id='O2xly'></ul>

                    <tbody id='O2xly'></tbody>
                  <tfoot id='O2xly'></tfoot>
                • <legend id='O2xly'><style id='O2xly'><dir id='O2xly'><q id='O2xly'></q></dir></style></legend>
                  本文介绍了使用用户名和密码时 RabbitMQ C# 连接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我在这里不知所措,所以我正在寻求集体知识,希望能出现奇迹.

                  I am at a loss here so I'm reaching out to the collective knowledge in hope of a miracle.

                  我已经使用默认设置在 Linux 机器上安装了 RabbitMQ.

                  I have installed RabbitMQ on a Linux box using the defaults.

                  当我使用此代码(以及默认的 RabbitMQ 安装配置)时,一切正常.

                  When I use this code (and the default RabbitMQ installation configuration) everything works nice.

                  var connectionFactory = new ConnectionFactory();
                  connectionFactory.HostName = "192.168.0.12";
                  IConnection connection = connectionFactory.CreateConnection();
                  

                  但是当我将用户添加到 RabbitMQ 并尝试使用以下代码时(用户名和密码已更改以保护无辜.:))

                  But when I add a user to RabbitMQ and try to use the following code (username and password has been changed to protect the innocent. :) )

                  var connectionFactory = new ConnectionFactory();
                  connectionFactory.HostName = "192.168.0.12";
                  connectionFactory.UserName = "user";
                  connectionFactory.Password = "password";
                  IConnection connection = connectionFactory.CreateConnection();
                  

                  connectionFactory.CreateConnection() 方法抛出以下异常:

                  BrokerUnreachableException    
                  None of the specified endpoints were reachable
                  

                  检查 RabbitMQ 日志文件,我可以看到它抱怨凭据:

                  Checking the RabbitMQ logfile I can see it complaining about the credentials:

                  {amqp_error,access_refused,
                  "PLAIN login refused: user 'user' - invalid credentials",
                  'connection.start_ok'}}
                  

                  问题是我对用户名和密码很有信心,但由于热爱编码,我无法在任何地方找到解决方案.

                  The thing is that I am confident about the username and password and I cannot for the love of coding find a solution to this anywhere.

                  我一定遗漏了一些明显的东西,但我不知道它是什么.如果有任何有用的指点,我将不胜感激.

                  I must be missing something obvious but I can't figure out what it is. I would be grateful for any helpful pointers.

                  推荐答案

                  看来我找到了解决自己问题的方法.以下代码有效:

                  It seems that I have found a solution to my own problem. The following code works:

                  ConnectionFactory factory = new ConnectionFactory();
                  factory.UserName = "user";
                  factory.Password = "password";
                  factory.VirtualHost = "/";
                  factory.Protocol = Protocols.FromEnvironment();
                  factory.HostName = "192.168.0.12";
                  factory.Port = AmqpTcpEndpoint.UseDefaultPort;
                  IConnection conn = factory.CreateConnection();
                  

                  感谢您的聆听,也许这至少对其他人有用.:)

                  Thanks for listening and perhaps this at least could be useful to someone else. :)

                  这篇关于使用用户名和密码时 RabbitMQ C# 连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:从客户端检查 RabbitMQ 队列大小 下一篇:如何使用 EasyNetQ/RabbitMQ 进行错误处理

                  相关文章

                  最新文章

                  1. <legend id='rH3A8'><style id='rH3A8'><dir id='rH3A8'><q id='rH3A8'></q></dir></style></legend>
                    <i id='rH3A8'><tr id='rH3A8'><dt id='rH3A8'><q id='rH3A8'><span id='rH3A8'><b id='rH3A8'><form id='rH3A8'><ins id='rH3A8'></ins><ul id='rH3A8'></ul><sub id='rH3A8'></sub></form><legend id='rH3A8'></legend><bdo id='rH3A8'><pre id='rH3A8'><center id='rH3A8'></center></pre></bdo></b><th id='rH3A8'></th></span></q></dt></tr></i><div id='rH3A8'><tfoot id='rH3A8'></tfoot><dl id='rH3A8'><fieldset id='rH3A8'></fieldset></dl></div>
                    <tfoot id='rH3A8'></tfoot>
                      • <bdo id='rH3A8'></bdo><ul id='rH3A8'></ul>

                    1. <small id='rH3A8'></small><noframes id='rH3A8'>