我正在尝试使用 EasyNetQ 连接到 RabbitMQ。 RabbitMQ 位于远程虚拟机上。
_rabbitBus = RabbitHutch.CreateBus(
string.Format("host={0};virtualhost={1}",
_hostSettings.Host, _hostSettings.VHost),
x => x.Register<IEasyNetQLogger>(l => _logger));
_rabbitBus.Subscribe<Message>(_topic, ReceiveMessage, m => m.WithTopic(_topic));
我得到一个 TimeoutException PersistentChannel 上请求的操作超时。
。
远程虚拟机正在回复 ping,端口 5672 和 15672 已打开(使用 nmap 检查)。
可以从我的主机访问 RabbitMQ 管理。
此外,如果 RabbitMQ 在我的本地计算机上运行,则它可以正常工作。 我尝试从局域网中的其他电脑连接到我的电脑上安装的 RabbitMQ,它也可以工作。
我得出一个假设,这与它在虚拟机上的事实有关,并且可能存在一些问题。不过,Rabbit 的网络管理工作正常。
还在 EasyNetQ Test 应用程序上进行了测试 - 可在本地主机上运行,但不能在远程上运行。
输出如下:
DEBUG: Trying to connect
ERROR: Failed to connect to Broker: '192.168.0.13', Port: 5672 VHost: '/'.
ExceptionMessage: 'None of the specified endpoints were reachable'
ERROR: Failed to connected to any Broker. Retrying in 5000 ms
- EasyNetQ v0.28.4.242
最佳答案
正如迈克建议的那样,我有这个,然后检查了权限。 “guest”用户只能通过 localhost 连接(请参阅 RabbitMQ Access Control 。)尝试使用管理界面添加具有权限的用户,然后按如下方式连接
var _bus = RabbitHutch.CreateBus(string.Format("host={0};virtualhost={1};username={2};password={3}",
_hostSettings.Host, _hostSettings.VHost, _hostSettings.UserName, _hostSettings.Password));
关于rabbitmq - EasyNetQ 无法发布到 RabbitMQ - PersistentChannel 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22882318/