Access to local MQ broker blocked despite AccessRights.FullAccess

Created at 25 Feb 2021, 20:09
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
IC

icoboyadzhiev

Joined 25.02.2021

Access to local MQ broker blocked despite AccessRights.FullAccess
25 Feb 2021, 20:09


The below snippet sends a message through RabbitMQ. It assumes the RabbitMQ server to be running with no authentication.

Inside the Main function of a simple C# program, this successfully sends the message and displays the result.

However, the same code used in the OnStart method of a Bot with AccessRights.FullAccess (Console.WriteLine replaced with Print) crashes with "BrokerUnreachableException: None of the specified endpoints were reachable".

How do I get my Bot to reach the broker?

 

using System;
using System.Text;

using RabbitMQ.Client;
using RabbitMQ.Client.Events;

namespace helloworld
{
    class Program
    {
        static void Main(string[] args)
        {
            string queueName = "signal";
            string exchangeName = "";
            string routingKey = "";

            var factory = new ConnectionFactory() { HostName = "localhost" };
            using (var connection = factory.CreateConnection())
            using (var channel = connection.CreateModel())
            {
                channel.QueueDeclare(queue: queueName,
                                     durable: false,
                                     exclusive: false,
                                     autoDelete: false,
                                     arguments: null);

                string message = "Hello World!";
                var body = Encoding.UTF8.GetBytes(message);

                channel.BasicPublish(exchange: "",
                                     routingKey: queueName,
                                     basicProperties: null,
                                     body: body);
                Console.WriteLine(" [x] sent {0}", message);
            }
        }
    }
}

 


@icoboyadzhiev