简体   繁体   中英

How to connect Remote RabbitMQ Server

I am going to build application (Asp.net C#) to connect RabbitMQ server which is in another country.

So my question is how to connect that server. I already installed RabbitMQ Client from NuGet Packages.

Is that needed to run RabbitMQ service in my local machine ?

Need to install RabbitMQ Server in my local machine?

From Client some of the parameters i got like UserName, Password, HostName, Certificate with private key.

I am curious to know which are the basic steps to connect that server from my localhost application.

Can someone provide blog to refer ? I already tried with different steps but not able to connect.

            string vCertSubjectName = "CN=DevRepo, OU=IT, O=OLX, L=KTM, S=Surrey, C=UK";
            ConnectionFactory factory = new ConnectionFactory();
            factory.AuthMechanisms = new AuthMechanismFactory[] { new ExternalMechanismFactory() };
            factory.HostName = "195.168.0.15";
            factory.Port = 5673;
            factory.Ssl.Certs = getCertificate(vCertSubjectName);
            factory.Ssl.ServerName = System.Net.Dns.GetHostName();
            factory.Ssl.Enabled = true;
            factory.Ssl.Version = SslProtocols.Tls12;
            IConnection connection = factory.CreateConnection();

Error coming like connection.start was never received, likely due to a network timeout."

There are very good simple examples of how to write code to send and receive messages to/from RabbitMQ on their site.

Get those examples; set up a RabbitMQ server on your local network; build the examples and verify they work. Once you know how to send/receive to/from a known instance, you can change the connection properties in your send program to point it to the RabbitMQ instance elsewhere.

I would also suggest you do a ping to the IP address of the foreign RabbitMQ server to get an idea of actual transit times. That should give you some idea if the network timeout is a valid issue.

PS. You will need a valid login and password for the RabbitMQ server before it will accept any messages from you. When you build the example programs above as long as you are on the same physical machine where RabbitMQ is running, you can use the default login and password of guest/guest. By default this will NOT work from another machine due to default security configuration of RabbitMQ.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM