Passing URI to RabbitMQ
17,048
Solution 1
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.
Solution 2
you can try this:-
string rabbitmqconnection = $"amqp://{HttpUtility.UrlEncode("username")}:
{HttpUtility.UrlEncode("password")}@{"hostname"}
/{HttpUtility.UrlEncode("/vhost")}";
hope this will resolve your problem.
Solution 3
You need to URLEncode
to the symbol @
in the password.
According to your situation, you can try this uri:
amqp://userid:mypass%4025@myrabbitserver:5672/filestream
Comments
-
techspider almost 2 years
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:
amqp://userid:mypass@25@myrabbitserver:5672/filestream
My password has
@
character due to which I'm not able to pass URIvar 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%40
, it throws an error when acquiring the connectionNone of the specified endpoints were reachable
-
techspider about 8 yearsi'm trying from App.config only; I pasted here for easy reference for others; your syntax ins config is still using @server/vhost; do you mean I remove /vhost?
-
jhilden about 8 yearsa vhost (virtual host) is a concept in rabbit to separate different queues for different users. If you don't need it, you can omit it. Also, my code works great from both web.config or app.config
-
techspider about 8 yearsdo you have @ symbol in your password?
-
jhilden about 8 yearsno, the @ symbol is the separator between the password and the name of the server
-
techspider about 8 yearsyes, I have @ in my password too; that's causing the confusion for RabbitMQ
-
teo van kot over 7 yearsWhat do you mean by "why"?