techspider techspider - 1 year ago 118
C# Question

Passing URI to RabbitMQ

I am connecting to RabbitMQ using below code

factory.UserName = "userid";
factory.Password = "mypass@25";
factory.VirtualHost = "/filestream";
factory.Port = AmqpTcpEndpoint.UseDefaultPort;
factory.HostName = "myrabbitserver";
return factory.CreateConnection();

I wanted to change connection settings to the below format:


My password has
character due to which I'm not able to pass URI

var factory = new ConnectionFactory();
factory.Uri = "amqp://userid:mypass@25@myrabbitserver:5672/filestream";

I end up supplying each attribute of factory manually. Is there a way that we can tell RabbitMQ that my password has @ by doing something like below?

factory.Uri = "amqp://userid:"mypass@25"@myrabbitserver:5672/filestream";

If I try to change
in the password to
, it throws an error when acquiring the connection

None of the specified endpoints were reachable

Answer Source

Apparently, there is no way to encode or escape the @ character in password. I changed password for the user to avoid this character and everything worked as expected.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download