Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RabbitMQ Connection Error " None of the specified endpoints were reachable"

I installed rabbitmq service on the server and on my system. I want to use RPC pattern:

var factory = new ConnectionFactory() { 
  HostName = "158.2.14.42", 
  Port = Protocols.DefaultProtocol.DefaultPort, 
  UserName = "Administrator", 
  Password = "@server@", 
  VirtualHost = "/"
  ContinuationTimeout = new TimeSpan(10, 0, 0, 0) 
};

connection = factory.CreateConnection();

I have an error on creating connection with this message:
None of the specified endpoints were reachable

When I use it on localhost instance of the server it works, but when I create the connection from local to that server,it returned the error. It not work with local ip and username and password of the my local computer.


Can anyone help me?

like image 676
parsa Avatar asked Dec 18 '17 13:12

parsa


3 Answers

Thank you all. As this :
https://stackoverflow.com/questions/4987438/rabbitmq-c-sharp-connection-trouble-when-using-a-username-and-password
After I installed RabbitMQ, I enabled management tools at the server and on my local computer with this:

rabbitmq-plugins enable rabbitmq_management

Then I restarted RabbitMQ service from services.msc
I could see the rabbitmq management at http://localhost:15672
I loginned to rabbit management with user:guest and pass:guest
I added my favorite user pass with administrator access, so it worked.

like image 195
parsa Avatar answered Oct 22 '22 03:10

parsa


I was also facing the same issue and later realized I have to open both ports i.e. 15672 and 5672.

The below command works for me in the docker container model.

docker run -it --rm --name mymq -p 5672:5672 -p 15672:15672 rabbitmq:3-management

Code snippet:

 var factory = new RabbitMQ.Client.ConnectionFactory
            {
                Uri = new Uri("amqp://guest:guest@localhost:5672/")
            };

or

var factory = new ConnectionFactory() { HostName = "localhost" };
like image 20
nitin gupta Avatar answered Oct 22 '22 04:10

nitin gupta


Do not use guest. Create your own account and password, and in http://localhost:15672/#/users , ensure "can access virtual hosts " is "/"

var factory = new ConnectionFactory() { 
  HostName = "192.168.1.121",
  Port = 5672,
  UserName = "fancky", 
  Password = "123456" 
};
like image 2
fancky Avatar answered Oct 22 '22 03:10

fancky