How to change rmq user password through coding

21 views
Skip to first unread message

mahendra naikwadi

unread,
Jul 31, 2020, 2:47:26 AM7/31/20
to rabbitmq-users
Hi,

I have configured one user with some password which is already in my client application. When I am sending notification with given credential it working fine. But, when I passed wrong password, hot is unreachable (refused connection due to invalid password). For this I want to change my rmq password when I am changing my client password and establish connection with RMQ with new password. Please suggest me to get it work. 
Hope you will get my point.

Wesley Peng

unread,
Jul 31, 2020, 3:29:40 AM7/31/20
to rabbitm...@googlegroups.com
Hi
You can change passwd via rabbitmqctl, the command line tool.

Also you can use the HTTP API to manage the password.

Here is my code (ruby):

def initialize(admin_host,mq_host,mq_port,mq_user,mq_pass)
@mq_host = mq_host
@mq_port = mq_port
endpoint = "http://#{admin_host}:15672"
@client = RabbitMQ::HTTP::Client.new(endpoint, :username =>
mq_user, :password => mq_pass)
end

def create_mq_dsn
vhost = "/" + SecureRandom.hex(6)
user = SecureRandom.hex(6)
pass = SecureRandom.hex(8)
@client.create_vhost(vhost)
@client.update_user(user, :tags => "autodeploy", :password => pass)
@client.update_permissions_of(vhost, user, :write => ".*",
:read => ".*", :configure => ".*")

dsn = {:host => @mq_host, :port => @mq_port, :vhost => vhost,
:user => user, :pass => pass}
return dsn
end

mahendra naikwadi

unread,
Jul 31, 2020, 4:19:30 AM7/31/20
to rabbitmq-users
Hi,

Thanks for you replay, but, Sorry, I am not aware about ruby. Is it possible to post in C#?

Wesley Peng

unread,
Jul 31, 2020, 4:39:21 AM7/31/20
to rabbitm...@googlegroups.com
Hi

mahendra naikwadi wrote:
> Thanks for you replay, but, Sorry, I am not aware about ruby. Is it
> possible to post in C#?

You probably want to read the HTTP API documentation:
https://rawcdn.githack.com/rabbitmq/rabbitmq-management/v3.8.5/priv/www/api/index.html

And try to find a c# client library for this purpose.

Regards.

mahendra naikwadi

unread,
Jul 31, 2020, 7:09:35 AM7/31/20
to rabbitmq-users
Not looking any api for password update.
Reply all
Reply to author
Forward
0 new messages