title: How to send message in rabbitmq on docker?
body: <p>Again, it supposed to be simple, but wasn't able to find any documentation about it</p>
  
  <p>In my previous <a href="https://stackoverflow.com/questions/47290108/how-to-open-rabbitmq-in-browser-using-docker-container">question</a> I had a problems with running rabbitmq container in docker. It has been solved, but now another one appeared</p>
  
  <p>Container was created with this line</p>
  
  <pre><code>docker run -d --hostname my-rabbit --name some-rabbit -p 15672:15672 rabbitmq:3-management
  </code></pre>
  
  <p>I was trying to create a simple console application to check how message sending is working (from <a href="https://www.rabbitmq.com/tutorials/tutorial-one-dotnet.html" rel="noreferrer">base tutorial</a>):</p>
  
  <pre><code>var factory = new ConnectionFactory()
  {
    HostName = "localhost",
    Port = 15672
  };
  
  using (var connection = factory.CreateConnection())
  {
    using (var channel = connection.CreateModel())
    {
      channel.QueueDeclare("Test", false, false, false, null);
  
      var mess = new RepMessage()
      {
         ConnectionString = "TestingString",
         QueueID = 5
      };
  
      var jsonified = JsonConvert.SerializeObject(mess);
      var messBody = Encoding.UTF8.GetBytes(jsonified);
      channel.BasicPublish("", "Test", null, messBody);
  
      Console.WriteLine(string.Format("Message with ConStr={0}, QueueID={1} has been send", mess.ConnectionString, mess.QueueID));
    }
  }
  </code></pre>
  
  <p>And result is, its not working.
  I am receiving exception <code>None of the specified endpoints were reachable</code> and inner exception as <code>connection.start was never received, likely due to a network timeout</code></p>
  
  <p>If I remove port, then my inner exception transforms in <code>No connection could be made because the target machine actively refused it 127.0.0.1:5672</code></p>
  
  <p>What am I missing, is is this example not supposed to work with docker?</p>