我尝试使用MassTransit
使用以下代码连接到特定的RabbitMq计算机var bus = ServiceBusFactory.New(x =>
{
x.UseRabbitMq();
x.ReceiveFrom("rabbitmq://admin:admin@<IP Address>/somequeue");
moreInitialization(x);
});
我在vhost&#34; \&#34;中创建了一个用户管理员具有管理员权限。
cmd:> rabbitmqctl list_permissions
Listing permissions in vhost "/" ...
admin .* .* .*
我删除了&#34;来宾&#34;用户。即使我使用下面的代码,我也可以在rabbitmq日志中看到如下
=ERROR REPORT==== 21-Jun-2015::12:19:22 ===
closing AMQP connection <0.391.0> (192.168.6.1:7000 -> 192.168.6.131:5672):
{handshake_error,starting,0,
{amqp_error,access_refused,
"PLAIN login refused: user 'guest' - invalid credentials",
'connection.start_ok'}}
在申请方面,我收到以下错误
Exception:Thrown: "ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile." (RabbitMQ.Client.Exceptions.AuthenticationFailureException)
A RabbitMQ.Client.Exceptions.AuthenticationFailureException was thrown: "ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile."
我是否需要更改rabbitmq.config文件中的任何配置?我使用的是RabbitMq Server版本3.5.3
感谢您的帮助
答案 0 :(得分:2)
要指定凭据,您需要显式配置主机。由于安全凭证泄漏,不再支持@语法。
例如:
var bus = ServiceBusFactory.New(sbc =>
{
sbc.UseRabbitMq(r => r.ConfigureHost(new Uri("rabbitmq://actual-server-name/queue-name"), h =>
{
h.SetUsername("username");
h.SetPassword("password");
}));
sbc.ReceiveFrom("rabbitmq://actual-server-name/queue-name");
});