无法连接远程 RabbitMQ 服务器
Unable to connect with remote RabbitMQ server
我正在创建一个客户端应用程序,目的是将新消息发布到远程 RabbitMQ 队列。我正在使用 MassTransit 创建此客户端,我的代码如下所示:
static IBusControl CreateBus()
{
return Bus.Factory.CreateUsingRabbitMq(x =>
{
var host = x.Host(new Uri(ConfigurationManager.AppSettings["RabbitMQHost"]), h =>
{
h.Username("user");
h.Password("password");
});
});
}
static IRequestClient<ISyncProject, IProjectSynced> CreateRequestClient(IBusControl busControl)
{
var serviceAddress = new Uri(ConfigurationManager.AppSettings["ServiceAddress"]);
IRequestClient<ISyncProject, IProjectSynced> client =
busControl.CreateRequestClient<ISyncProject, IProjectSynced>(serviceAddress, TimeSpan.FromDays(1));
return client;
}
private static async Task MainLogic(IBusControl busControl)
{
IRequestClient<ISyncProject, IProjectSynced> client = CreateRequestClient(busControl);
//I'm using the client here as I show below, this part is not important it works with localhost
IProjectSynced response = await client.Request(new ProjecToSync() { OriginalOOMID = OriginalOOMID });
}
配置文件如下所示:
<appSettings>
<add key="RabbitMQHost" value="rabbitmq://ServerName" />
<add key="ServiceQueueName" value="queueName" />
<add key="ServiceAddress" value="rabbitmq://ServerName/queueName" />
</appSettings>
我没有使用来宾用户,我创建了一个新用户并添加了管理员的所有权限。
现在,如果我 运行 客户端应用程序在 运行 正在使用 RabbitMQ 的同一服务器中,并且还将 ServerName
更改为 localhost
,则此代码可以正常工作。如果我 运行 本地计算机中的客户端使用服务器的任何 ServerName 或 IP 地址,RabbitMQ 会阻止我的连接:
我想这一定是我需要在服务器中进行的一些配置,但到目前为止我还没有找到它。
我现在注意到的一件事是磁盘 space 是红色的,并且已经创建了大量的通用交换
正如你的问题所示,在底部你有一个连接,但它被阻止了。
The RabbitMQ documentation 列出了连接被阻止的一些情况。这些通常与代理机器本身的资源限制有关。在这种情况下,我们已经设法清楚地了解代理可用的可用磁盘 space 低于其 low-water 标记。因此,所有连接都将被阻止,直到此条件得到解决(降低标记 - 不推荐,或增加可用的免费 space)。
我正在创建一个客户端应用程序,目的是将新消息发布到远程 RabbitMQ 队列。我正在使用 MassTransit 创建此客户端,我的代码如下所示:
static IBusControl CreateBus()
{
return Bus.Factory.CreateUsingRabbitMq(x =>
{
var host = x.Host(new Uri(ConfigurationManager.AppSettings["RabbitMQHost"]), h =>
{
h.Username("user");
h.Password("password");
});
});
}
static IRequestClient<ISyncProject, IProjectSynced> CreateRequestClient(IBusControl busControl)
{
var serviceAddress = new Uri(ConfigurationManager.AppSettings["ServiceAddress"]);
IRequestClient<ISyncProject, IProjectSynced> client =
busControl.CreateRequestClient<ISyncProject, IProjectSynced>(serviceAddress, TimeSpan.FromDays(1));
return client;
}
private static async Task MainLogic(IBusControl busControl)
{
IRequestClient<ISyncProject, IProjectSynced> client = CreateRequestClient(busControl);
//I'm using the client here as I show below, this part is not important it works with localhost
IProjectSynced response = await client.Request(new ProjecToSync() { OriginalOOMID = OriginalOOMID });
}
配置文件如下所示:
<appSettings>
<add key="RabbitMQHost" value="rabbitmq://ServerName" />
<add key="ServiceQueueName" value="queueName" />
<add key="ServiceAddress" value="rabbitmq://ServerName/queueName" />
</appSettings>
我没有使用来宾用户,我创建了一个新用户并添加了管理员的所有权限。
现在,如果我 运行 客户端应用程序在 运行 正在使用 RabbitMQ 的同一服务器中,并且还将 ServerName
更改为 localhost
,则此代码可以正常工作。如果我 运行 本地计算机中的客户端使用服务器的任何 ServerName 或 IP 地址,RabbitMQ 会阻止我的连接:
我想这一定是我需要在服务器中进行的一些配置,但到目前为止我还没有找到它。
我现在注意到的一件事是磁盘 space 是红色的,并且已经创建了大量的通用交换
正如你的问题所示,在底部你有一个连接,但它被阻止了。
The RabbitMQ documentation 列出了连接被阻止的一些情况。这些通常与代理机器本身的资源限制有关。在这种情况下,我们已经设法清楚地了解代理可用的可用磁盘 space 低于其 low-water 标记。因此,所有连接都将被阻止,直到此条件得到解决(降低标记 - 不推荐,或增加可用的免费 space)。