Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rabbitMQ.Client in .NET System.IO.IOException: connection.start was never received, likely due to a network timeout

Tags:

asp.net

ssl

amqp

I am writing amqp 1.0 client (using rabbitMQ.Client in .NET) for a broker who provided me the following information:

  • amqps://brokerRemoteHostName:5671
  • certificate_openssl.p12
  • password for certificate as a string "mypassword"
  • queue name

I developed the following code in Visual Studio which is supposed to work (based on long searches on the web):

var cf = new ConnectionFactory();             
cf.Uri = new Uri("amqps://brokerRemoteHostName:5671");
cf.Ssl.Enabled = true;
cf.Ssl.ServerName = "brokerRemoteHostName";
cf.Ssl.CertPath = @"C:\Users\mahmoud\Documents\certificate_openssl.p12";
cf.Ssl.CertPassphrase = "myPassword";
var connection = cf.CreateConnection();

However, the output shows an exception:

RabbitMQ.Client.Exceptions.BrokerUnreachableException:
None of the specified endpoints were reachable ---> System.IO.IOException:
connection.start was never received

likely due to a network timeout) as seen in the image.

Where line 50 corresponds to the line where we create the connection.

I appreciate your kind assistance on the error above.

like image 870
RabbitUser Avatar asked Oct 17 '17 22:10

RabbitUser


People also ask

How do I connect to RabbitMQ client?

In order for a client to interact with RabbitMQ it must first open a connection. This process involves a number of steps: Application configures the client library it uses to use a certain connection endpoint (e.g. hostname and port) The library resolves the hostname to one or more IP addresses.

Can't connect to RabbitMQ?

Make sure the node is running using rabbitmq-diagnostics status. Verify config file is correctly placed and has correct syntax/structure. Inspect listeners using rabbitmq-diagnostics listeners or the listeners section in rabbitmq-diagnostics status. Inspect effective configuration using rabbitmq-diagnostics environment.


1 Answers

If you're connecting to a docker container, you need to add the 5672 port in addition to 15672 port when creating the container. For those using ssl, the port would be 5671 instead of 5672.

Example: docker run -d --hostname my-rabbit --name rabbitmq --net customnet -p customport:15672 -p 5672:5672 rabbitmq:3-management.

You would connect from client by calling this: ConnectionFactory factory = new ConnectionFactory() { HostName = "localhost" };.

Feel free to pass in username and password if those were changed.

like image 138
CLUTCHER Avatar answered Sep 18 '22 12:09

CLUTCHER