RabbitMQ.Client.Exceptions.BrokerUnreachableException: 'None of the specified endpoints were reachab

16,838 views
Skip to first unread message

Ozi

unread,
May 16, 2017, 2:20:56 AM5/16/17
to rabbitmq-users
Hi

Just trying to get the tutorial to work. I'm on windows 10 with VS 2017, with both erlag and rabbitmq installed and running.

It fails trying to do:
 using(var connection = factory.CreateConnection())

using System;
using RabbitMQ.Client;
using System.Text;

class Program
{
    public static void Main()
    {
        var factory = new ConnectionFactory() { HostName = "localhost" };
        using(var connection = factory.CreateConnection())
        using(var channel = connection.CreateModel())
        {
            channel.QueueDeclare(queue: "hello", durable: false, exclusive: false, autoDelete: false, arguments: null);

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

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

        Console.WriteLine(" Press [enter] to exit.");
        Console.ReadLine();
    }
}


RabbitMQ.Client.Exceptions.BrokerUnreachableException occurred
  HResult=0x80131620
  Message=None of the specified endpoints were reachable
  Source=RabbitMQ.Client
  StackTrace:
   at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)
   at RabbitMQ.Client.ConnectionFactory.CreateConnection()
   at Program.Main() in C:\Working\Development\dotnet-visual-studio\1_Send\Program.cs:line 10

Inner Exception 1:
ConnectFailureException: Connection failed

Inner Exception 2:
SocketException: No connection could be made because the target machine actively refused it

I need to get this to work for a demo next week.

Cheers
Ozi

Karl Nilsson

unread,
May 16, 2017, 2:26:59 AM5/16/17
to rabbitm...@googlegroups.com
Hi,

Are you confident RabbitMQ is running on localhost on port 5672? Can you check in your services and confirm the service is actually started and running. Failing that you may want to inspect the broker logs to see if anything has gone wrong during startup.

Cheers
Karl

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Karl Nilsson

Pivotal/RabbitMQ

Ozi

unread,
May 16, 2017, 2:46:39 AM5/16/17
to rabbitmq-users
Hi Karl

Yes I can confirm that the service is running.

"C:\Program Files\erl8.3\erts-8.3\bin\erlsrv.exe"

Karl Nilsson

unread,
May 16, 2017, 4:36:23 AM5/16/17
to rabbitm...@googlegroups.com
Could you use telnet or netstat to check that the socket is actually listening and accepting connections?

e.g: 

telnet localhost 5672



--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Karl Nilsson

Pivotal/RabbitMQ

Michael Klishin

unread,
May 16, 2017, 4:39:37 AM5/16/17
to rabbitm...@googlegroups.com
An important note: if you don't provide a valid protocol preamble after connecting with telnet,
RabbitMQ will close the connection after several seconds (5 or 10 by default, IIRC).

This is expected.
> > email to rabbitmq-user...@googlegroups.com.
> > To post to this group, send email to rabbitm...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
> >
>
>
>
> --
> Karl Nilsson
>
> Pivotal/RabbitMQ
>
> --
> You received this message because you are subscribed to the Google Groups "rabbitmq-users"
> group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
> To post to this group, send an email to rabbitm...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

--
MK

Staff Software Engineer, Pivotal/RabbitMQ


Ozi

unread,
May 16, 2017, 5:45:28 PM5/16/17
to rabbitmq-users
The debug message I'm getting is :

SocketErrorCode : ConnectionRefused  -  System.Net.Sockets.SocketError

No connection could be made because the target machine actively refused it 127.0.0.1:5672

   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
   at System.Net.Sockets.Socket.Connect(IPAddress address, Int32 port)
   at RabbitMQ.Client.TcpClientAdapter.<ConnectAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at RabbitMQ.Client.Impl.TaskExtensions.<TimeoutAfter>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at RabbitMQ.Client.Impl.SocketFrameHandler.Connect(ITcpClient socket, AmqpTcpEndpoint endpoint, Int32 timeout)

ErrorCode 10061


TargetSite {T SelectOne[T](RabbitMQ.Client.IEndpointResolver, System.Func`2[RabbitMQ.Client.AmqpTcpEndpoint,T])} System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}

Michael Klishin

unread,
May 16, 2017, 5:47:42 PM5/16/17
to rabbitm...@googlegroups.com
"actively refused it" is networking speak for "there was no listener on that interface and port"
or that the connection was rejected e.g. by the firewall or a security tool.

To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Ozi

unread,
May 16, 2017, 6:59:38 PM5/16/17
to rabbitmq-users
Another dev on win 7 has it working, but I'll take the issue up the our network people.

Thanks

Michael Klishin

unread,
May 16, 2017, 7:01:52 PM5/16/17
to rabbitm...@googlegroups.com, Ozi
Since you are connecting to localhost the matter likely has nothing to do with
networking per se.

Either the node isn't running, or it bindings to a different interface (by default: all interfaces available),
or it uses a different port, or something prevents the client from opening a TCP connection to that port. 

On 16 May 2017 at 23:59:45, Ozi (ozitra...@gmail.com) wrote:
> Another dev on win 7 has it working, but I'll take the issue up the our
> network people.
>
> Thanks
>
> On Wednesday, May 17, 2017 at 7:47:42 AM UTC+10, Michael Klishin wrote:
> >
> > "actively refused it" is networking speak for "there was no listener on
> > that interface and port"
> > or that the connection was rejected e.g. by the firewall or a security
> > tool.
> >
> > On Tue, May 16, 2017 at 10:45 PM, Ozi >
> > wrote:
> >
> >> The debug message I'm getting is :
> >>
> >> SocketErrorCode : ConnectionRefused - System.Net.Sockets.SocketError
> >>
> >> No connection could be made because the target machine actively refused
> >> it 127.0.0.1:5672
> >>
> >> at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,
> >> SocketAddress socketAddress)
> >> at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
> >> at System.Net.Sockets.Socket.Connect(IPAddress address, Int32 port)
> >> at RabbitMQ.Client.TcpClientAdapter.d__2.MoveNext()
> >> --- End of stack trace from previous location where exception was thrown
> >> ---
> >> at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> >> task)
> >> at
> >> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> >> task)
> >> at RabbitMQ.Client.Impl.TaskExtensions.d__0.MoveNext()

Ozi

unread,
May 16, 2017, 7:22:10 PM5/16/17
to rabbitmq-users
I've given up on localhost, and am connected to rabbitmq in a docker container.

Thanks


On Tuesday, May 16, 2017 at 4:20:56 PM UTC+10, Ozi wrote:

Michael Klishin

unread,
May 16, 2017, 7:27:56 PM5/16/17
to rabbitm...@googlegroups.com, Ozi
That's an important piece of information that was not mentioned at the time you'd posted the stack trace.

While it shouldn't result in a "connection reset" with a modern version of the .NET client that supports
[1], please beware of the fact that user "guest" can only connect from localhost [2] by default.
Such authorization failures will be easily visible in the log.

1. https://www.rabbitmq.com/auth-notification.html
2. http://www.rabbitmq.com/access-control.html

Ozi

unread,
May 16, 2017, 8:33:51 PM5/16/17
to rabbitmq-users, ozitra...@gmail.com
I only managed to connect to rabbitMQ in docker this morning, after I spoke to another dev who managed to connect last night after I left.

The logs in AppData\Roaming\RabbitMQ\log are empty and erl_crash.dump only had a cookie error
Reply all
Reply to author
Forward
0 new messages