Error 500 on Broker page
Describe the bug Flower is deployed on Heroku and makes use of Heroku Redis as broker.
Heroku Redis uses self-signed certificates (hence the broker_use_ssl = {"ssl_cert_reqs": "none"} part in config below). And Workers / Tasks tabs work fine. Just the broker part is broken.
To Reproduce Steps to reproduce the behavior:
- Go to 'Broker' tab
- See error
[W 240227 06:47:49 connection:268] Secure redis scheme specified (rediss) with no ssl options, defaulting to insecure SSL behaviour.
[W 240227 06:47:49 connection:268] Secure redis scheme specified (rediss) with no ssl options, defaulting to insecure SSL behaviour.
[E 240227 06:47:49 broker:31] Unable to get queues: 'Error 1 connecting to ec2-52-45-116-60.compute-1.amazonaws.com:6379. [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1006).'
[W 240227 06:47:49 connection:268] Secure redis scheme specified (rediss) with no ssl options, defaulting to insecure SSL behaviour.
[E 240227 06:47:49 web:1875] Uncaught exception GET /broker ([10.1.39.250](https://my.papertrailapp.com/systems/flower-heroku/events?q=%2210.1.39.250%22&focus=1699101004400787463&selected=1699101004400787463))
HTTPServerRequest(protocol='http', host='flower-heroku.herokuapp.com', method='GET', uri='/broker', version='HTTP/1.1', remote_ip='[10.1.39.250](https://my.papertrailapp.com/systems/flower-heroku/events?q=%2210.1.39.250%22&focus=1699101004400787464&selected=1699101004400787464)')
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.11/site-packages/tornado/web.py", line 1790, in _execute
result = await result
^^^^^^^^^^^^
File "/app/.heroku/python/lib/python3.11/site-packages/flower/views/broker.py", line 35, in get
queues=queues)
^^^^^^
UnboundLocalError: cannot access local variable 'queues' where it is not associated with a value
Expected behavior Broker info is shown
Screenshots
System information
$ python -c 'from flower.utils import bugreport; print(bugreport())'
flower -> flower:2.0.1 tornado:6.4 humanize:4.9.0
software -> celery:5.3.6 (emerald-rush) kombu:5.3.5 py:3.11.8
billiard:4.2.0 py-amqp:5.2.0
platform -> system:Linux arch:64bit, ELF
kernel version:5.15.0-1053-aws imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:amqp results:disabled
deprecated_settings: None
Command line
celery --broker=$REDIS_URL/1 flower --port=$PORT --config flowerconfig
floweconfig.py
import os
basic_auth = [os.environ['BASIC_AUTH']]
broker_url = os.environ['REDIS_URL'] + '/1'
broker_use_ssl = {"ssl_cert_reqs": "none"}
timezone = os.getenv('TIMEZONE', 'US/Eastern')
Facing same error with RabbitMQ as broker when visiting Broker page
Facing the same issue with Redis on Redis Cloud
Ensure that the broker_api is set accordingly to your config: example:
--broker="amqp://guest:[email protected]:5672/
and
--broker-api="http://127.0.0.1:15672/api/
Note that the port change, as well as the auth isn't present in the settings (if you have one)
i'm not using AMQP. my broker is Redis
Same problem here using Flower flower==2.0.1 with Sentinel+Redis as broker
[E 240723 14:46:33 web:1875] Uncaught exception GET /flower/broker (1.2.3.4)
HTTPServerRequest(protocol='http', host='flower.example.com', method='GET', uri='/flower/broker', version='HTTP/1.1', remote_ip='1.2.3.4')
Traceback (most recent call last):
File "/home/vocalo/.venv/lib/python3.10/site-packages/tornado/web.py", line 1790, in _execute
result = await result
File "/home/vocalo/.venv/lib/python3.10/site-packages/flower/views/broker.py", line 35, in get
queues=queues)
UnboundLocalError: local variable 'queues' referenced before assignment
Quick update: I've also found logs like this:
Unable to get queues: 'unsupported operand type(s) for +: 'NoneType' and 'str''
I was able to fix the issue by setting global_keyprefix = ''
I guess global_keyprefix is set to None by default and it makes Broker page fail.
Same problem here using Flower
flower==2.0.1with Sentinel+Redis as broker[E 240723 14:46:33 web:1875] Uncaught exception GET /flower/broker (1.2.3.4) HTTPServerRequest(protocol='http', host='flower.example.com', method='GET', uri='/flower/broker', version='HTTP/1.1', remote_ip='1.2.3.4') Traceback (most recent call last): File "/home/vocalo/.venv/lib/python3.10/site-packages/tornado/web.py", line 1790, in _execute result = await result File "/home/vocalo/.venv/lib/python3.10/site-packages/flower/views/broker.py", line 35, in get queues=queues) UnboundLocalError: local variable 'queues' referenced before assignment
I had the same issue, and realized I had --broker-api=amqp://guest:guest@rabbitmq:15672/api, which I replaced with --broker-api=http://guest:guest@rabbitmq:15672/api (was amqp://, should have been http://) and the issue went away.
In the file where you have your сelery app, try replacing this:
app.conf.task_queues = {
"default": {"exchange": "default", "routing_key": "default"},
"notification": {"exchange": "notification", "routing_key": "notification"},
}
With this:
from kombu import Queue
app.conf.task_queues = (
Queue("default", routing_key="default"),
Queue("notification", routing_key="notification"),
)
Documentation: Celery Routing This solution worked for me
I've had this exact error and fixed it by including ssl_cert_reqs in my Celery() main config (broker_use_ssl={"ssl_cert_reqs": "none"}), not in the rediss:// URL.
I think it's because Celery supports this parameter in the redis URL, but not Flower: https://github.com/mher/flower/blob/d6898881a36945ebab86d6f00f1d2d16dbac7b06/flower/utils/broker.py#L214