How to find RabbitMQ URL? - rabbitmq

Rabbit MQ URL looks like :
BROKER_URL: "amqp://user:password#remote.server.com:port//vhost"
This is not clear where we can find the URL, login and password of RabbitMQ
when we need to acccess from remote worker (outside of Localhost).
In other way, how to set RabbitMQ IP adress, login and password from Celery / RabbitMQ

You can create new user for accessing your RabbitMQ broker.
Normally port used is 5672 but you can change it in your configuration file.
So suppose your IP is 1.1.1.1 and you created user test with password test and you want to access vhost "dev" (without quotes) then it will look something like this:
amqp://test:test#1.1.1.1:5672/dev
I will recommend to enable RabbitMQ Management Plugin to play around RabbitMQ.
https://www.rabbitmq.com/management.html

To add to the accepted answer:
As of 2022, the default username and password are guest
In my experience, ignoring vhost is safe while getting started with RabbitMQ
If using RabbitMQ as part of a Docker Compose setup (e.g. for testing), other containers in the same application should be able to access RabbitMQ via its service name. For example, if the name of the service in docker-compose.yml is rabbitmq, passing amqp://guest:guest#rabbitmq:5672/ should work

Related

i'm not able to do Publisher/Subscriber in rabbitmq in ubuntu22.04, i'm not finding anything about it

i'm not able to do Publisher/Subscriber in rabbitmq in ubuntu22.04, i'm not finding anything about it. I use docker for this, I can create the management with port 8080:15672, I cannot use 5672. And when I send some code to Publisher/Subscriber nothing appears in the management, (obs: I used http//localhost:8080 to access rabbitmq management)
Did you open traffic redirection to port 5672? For eg. If you are using docker run, then -p 5672:5672

OpenShift v3 connect app with redis. Connection Refused

I have created a redis 3.2 application from the default image catalog.
I'm trying to connect a python app that runs inside the same project with the redis db.
This is what the Python application uses to connect to redis:
REDIS_HOST = 'localhost'
REDIS_PORT = 6379
REDIS_PASSWORD = os.environ.get('REDIS_PASSWORD') or 'test'
redis = aioredis.create_redis_pool(
(REDIS_HOST, int(REDIS_PORT)),
password=REDIS_PASSWORD,
minsize=5,
maxsize=10,
loop=loop,
)
The deployment fails with an ConnectionRefusedError: [Errno 111] Connection refused.
My guess is that I need to use another value for REDIS_HOST, but I couldn't figure what to use.
Does anyone know how to fix this?
After you deployed from the image catalog a number of objects will have been created for you. One of those objects is a service, which is used to load balance requests to the Pods it fronts. Service names for a project can be retrieved using the client tools via oc get svc.
This service name should be used to connect to your redis instance. If you deploy redis before your Python application, some environment variables should already be populated which can be used, for example REDIS_SERVICE_HOST and REDIS_SERVICE_PORT.
So from your application you can connect via the service ip or service name, where service name is redis then redis.StrictRedis(host='redis', port=6379, password='secret')
The redis password may have been generated for you. In that case it is retrievable from the redis secret which could also be mounted from your python app
Databases in general do not use standard HTTP, but custom TCP protocols. This is why in Openshift we need to connect directly to the service using Openshift's Service hostname or IP address (caution: only Service hostname is predictable), instead of the usual Route, and this applies also to Redis. Bypassing the Routes in Openshift is like bypassing a reverse proxy such as nginx and directly connecting to the db backend.
There is need to use env variables, because service hostnames are auto-generated by Openshift using this predictable pattern:
container_name.project_name.svc , e.g:
redis.db.svc
More info
"When a web application is made visible outside of the OpenShift cluster a route is created. This enables a user to use a URL to access the web application from a web browser. A route is usually used for web applications which use the HTTP protocol. A route cannot be used to expose a database, as they would typically use their own distinct protocol, and routes would not be able to work with the database protocol."
[https://blog.openshift.com/openshift-connecting-database-using-port-forwarding/ ]

Is it possible to associate clients dynamically in sensu?

I'am using open source tools for the first time. I would like to install sensu, All i want to know that is there any method in which i can add my newly provisioned service automatically to the sensu server.
#vineesha We can make this possible when using rabbit mq, please write a script to fetch hostname and Ip address and update client.json and restart rabbitmq server and sensu-client. In the golden image please hard code the IP address of sensu server in rabbitmq.json. When all this is done please set a cron with #reboot and this should be all. When the server is launched it will automatically add to the sensu server.
If you are planning to use automation tools like for example puppet, all you need to do is to ensure that the sense-client is installed and the client config includes the correct RabbitMQ config.
As soon as the client connects to the same RabbitMQ host/cluster it should also pop up in you dashboard e.g. uchiwa.
There is no need to explicitly give the sense-server any information directly.

Java RabbitMQ configuration

I am new in using rabbitMQ and I am trying to sent an 'hello' message over internet,
I am implementing the example available in the rabbitMQ website Java RabbitMQ Hello world example, but in the example they use localhost, I try to change it to the IP address for the sender and receiver computer as explained at the website and put the sender code at a machine and receiver code on another, but it doesn't work.
My questions:
1) is rabbitMQ works over internet or it works just over local network?
2) in both cases, how to configure each computer and what each one should have?
3) Do I need to install rabbitMQ on both machines? or on one of them to run it a server?
Please if anyone can help me in configure them step-by-step, get me an answer with details.
It is a grant problem.
The user guest guest ( default for rabbitmq ) works only in localhost.
Please read this post:
Can't access RabbitMQ web management interface after fresh install
and also this:
RabbitMQ 3.3.1 can not login with guest/guest
To enable guest guest and/or create a new user.
The best practice is to create another user.
Let me answer your questions one by one
1) Yes. RabbitMQ should work over internet, you should be able to connect by giving the public ip of the RabbitMQ server. If you connecting to a server with username/password enabled then it should be provided while creating the connection.
ConnectionFactory factory = new ConnectionFactory();
factory.setUsername("username");
factory.setPassword("pwd");
2) One of the machines should have the RabbitMQ server(broker) installed and running. You can produce or consume messages from any of the machines using Java RabbitMQ client. If you had 3 machines then all three, the RabbitMQ server, message producer and message consumer could be on 3 machines.
3) You don't need to install RabbitMQ on both the machines. Install only on the machine which is running as server.

rabbitMQ federation ACCESS_REFUSED (guest login fail)

I have set up rabbitMQ federation between two machines A and B, bi-direction,
but have the error
{auth_failure,"ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile."}
in the log file, it seems the federation amqp need to access through guest/guest credential, this comes to the question here:
rabbitMQ guest login failed
with existing solution to set up test/test here :
Can't access RabbitMQ web management interface after fresh install
I tried to make guest/guest also work from another machine by running :
rabbitmqctl set_permissions -p / guest "." "." ".*"
but still fail to login via guest/guest on another machine,
in the rabbitMQ management web UI, the user test and guest look all the same:
Name
Tags
Can access virtual hosts Has password
guest
administrator / ●
test
administrator / ●
but why I still can't loging with guest/guest on another machine? (test/test works fine)
You are not listing what version you use, but guesstimating from your post time, I would say the issue is probably because in v 3.3.0 (released in early April 2014) they disabled guest user login remotely (see release notes here), AND it looks like at some point around that time there was a change either in the way federation is supposed to be setup, or simply the yanking of the guest user made it behave differently.
Anyway, to resolve this, make sure you create your upstream with an URI in the following form:
amqp://your_user:your_users_password#rabbit-node-FQDN.your.domain.com/your_vhost
the key is in the your_user:your_users_password string - that was not required before 3.3 (and it still may work without it should you enable the guest user... but I don't care to try that)
hth