[Error 500] GET prices/usd when rabbitmq is down
See original GitHub issueDescribe the bug Some 500 error are appearing in the logs when GET price/usd happen in the moment that rabbitmq is not responding for unknown reason.
To Reproduce Steps to reproduce the behavior:
- Clean readis cache and turn off rabbitmq container
- Then GET some token /prices/usd
- Inmediatly we get a 500 error
Expected behavior I think that should catch the exception and don’t delay the task to get the price and return the current price without 500 error. Exception traceback
2022-08-03 13:42:50,833 [ERROR] [MainProcess] Internal Server Error: /api/v1/tokens/0x0AaE289A554cB3C97b3121db837eD9ce8635367F/prices/usd/
Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/kombu/utils/functional.py", line 30, in __call__ return self.__value__AttributeError: 'ChannelPromise' object has no attribute '__value__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 446, in _reraise_as_library_errors yield File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 433, in _ensure_connection return retry_over_time( File "/usr/local/lib/python3.10/site-packages/kombu/utils/functional.py", line 312, in retry_over_time return fun(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 877, in _connection_factory self._connection = self._establish_connection() File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 812, in _establish_connection conn = self.transport.establish_connection() File "/usr/local/lib/python3.10/site-packages/kombu/transport/pyamqp.py", line 201, in establish_connection conn.connect() File "/usr/local/lib/python3.10/site-packages/amqp/connection.py", line 323, in connect self.transport.connect() File "/usr/local/lib/python3.10/site-packages/amqp/transport.py", line 129, in connect self._connect(self.host, self.port, self.connect_timeout) File "/usr/local/lib/python3.10/site-packages/amqp/transport.py", line 184, in _connect self.sock.connect(sa) File "/usr/local/lib/python3.10/site-packages/gevent/_socketcommon.py", line 607, in connect raise _SocketError(err, strerror(err))ConnectionRefusedError: [Errno 111] Connection refused
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) File "/usr/local/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python3.10/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view return view_func(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/django/views/generic/base.py", line 84, in view return self.dispatch(request, *args, **kwargs) File "/usr/local/lib/python3.10/site-packages/rest_framework/views.py", line 509, in dispatch response = self.handle_exception(exc) File "/usr/local/lib/python3.10/site-packages/rest_framework/views.py", line 469, in handle_exception self.raise_uncaught_exception(exc) File "/usr/local/lib/python3.10/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception raise exc File "/usr/local/lib/python3.10/site-packages/rest_framework/views.py", line 506, in dispatch response = handler(request, *args, **kwargs) File "/usr/local/lib/python3.10/site-packages/django/utils/decorators.py", line 46, in _wrapper return bound_method(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/django/utils/decorators.py", line 133, in _wrapped_view response = view_func(request, *args, **kwargs) File "/app/safe_transaction_service/tokens/views.py", line 92, in get fiat_price_with_timestamp = next( File "/app/safe_transaction_service/tokens/services/price_service.py", line 347, in get_cached_usd_values for token_eth_values_with_timestamp in self.get_cached_token_eth_values( File "/app/safe_transaction_service/tokens/services/price_service.py", line 324, in get_cached_token_eth_values task_result = calculate_token_eth_price_task.delay( File "/usr/local/lib/python3.10/site-packages/celery/app/task.py", line 425, in delay return self.apply_async(args, kwargs) File "/usr/local/lib/python3.10/site-packages/celery/app/task.py", line 575, in apply_async return app.send_task( File "/usr/local/lib/python3.10/site-packages/celery/app/base.py", line 788, in send_task amqp.send_task_message(P, name, message, **options) File "/usr/local/lib/python3.10/site-packages/celery/app/amqp.py", line 510, in send_task_message ret = producer.publish( File "/usr/local/lib/python3.10/site-packages/kombu/messaging.py", line 177, in publish return _publish( File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 523, in _ensured return fun(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/kombu/messaging.py", line 186, in _publish channel = self.channel File "/usr/local/lib/python3.10/site-packages/kombu/messaging.py", line 209, in _get_channel channel = self._channel = channel() File "/usr/local/lib/python3.10/site-packages/kombu/utils/functional.py", line 32, in __call__ value = self.__value__ = self.__contract__() File "/usr/local/lib/python3.10/site-packages/kombu/messaging.py", line 225, in <lambda> channel = ChannelPromise(lambda: connection.default_channel) File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 895, in default_channel self._ensure_connection(**conn_opts) File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 432, in _ensure_connection with ctx(): File "/usr/local/lib/python3.10/contextlib.py", line 153, in __exit__ self.gen.throw(typ, value, traceback) File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 450, in _reraise_as_library_errors raise ConnectionError(str(exc)) from exckombu.exceptions.OperationalError: [Errno 111] Connection refused
Issue Analytics
- State:
- Created a year ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
RabbitMQ fail with HTTP 500: Internal Server Error #332
I am using Celery Flower with RabbitMQ as message broker. However I am getting nasty error ERROR - RabbitMQ management API call failed:...
Read more >RabbitMQ management returns 500 when trying to list queues
I upgraded RabbitMQ to 3.6.5 and the error got resolved. It is now working with Erlang 19.0.
Read more >Reliability Guide - RabbitMQ
Reliability Guide. Overview. This guides provides an overview features of RabbitMQ, AMQP 0-9-1 and other supported protocols related to data safety.
Read more >Queue status was "down" and then RabbitMQ became non ...
I had the chance to see this State in the Management console, tried to switch to Overview and ever since I get this...
Read more >Troubleshooting RabbitMQ - SolarWinds Success Center
On the main polling engine, navigate to the installation directory (C:\Program Files (x86)\SolarWinds\Orion by default) and find ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Added
Then 500 for this case is correct. Closing the issue.