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

2

12

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.

Keystone answered 17/10, 2017 at 22:20 Comment(5)
getting same issue any updated with this ?Testa
Did you solve this issue?Starbuck
having the same issue, is the question died? anyone solved this?Kevenkeverian
@Kevenkeverian I wrote a solution.Languorous
@CLUTCHER, This solution is only when using docker. Has anyone found a solution?Highway
L
2

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.

Languorous answered 4/8, 2020 at 5:59 Comment(0)
S
2

Official RabbitMq docker image https://hub.docker.com/_/rabbitmq starts RabbitMq broker on port 5672, but .NET RabbitMq library expects to see broker on port 5673 which for sure differs from what we have in fact in docker. The solution is just to remap 5672 to expected 5673 port

docker run -d --hostname my-rabbit --name ds-rabbit -p 8080:15672 -p 5673:5672 rabbitmq:3-management
Souvaine answered 14/10, 2021 at 15:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.