Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'ChannelPromise' object has no attribute '__value__' #369

Closed
davidfischer-ch opened this issue Jun 10, 2014 · 35 comments
Closed

Comments

@davidfischer-ch
Copy link

pip freeze:

-e git://github.com/django/django.git@df09d854828bcff56eb72f48ff1ba8fce7e90c90#egg=Django-origin/HEAD
Jinja2==2.7.3
MarkupSafe==0.23
-e git://github.com/python-imaging/Pillow@24cb7bf3df6660bb2bd705b3197e97947dd40a50#egg=Pillow-dev
PyYAML==3.11
Pygments==1.6
Unidecode==0.04.16
-e git://github.com/celery/py-amqp.git@6b945b7065bd3bc53142e2d3f1d520d6f4a3d2de#egg=amqp-origin/master
anyjson==0.3.3
argparse==1.2.1
-e git://github.com/celery/billiard.git@0c8b96c47551f4f0d2d58c53dda7251bcf03236c#egg=billiard-origin/HEAD
bpython==0.12
-e git://github.com/celery/celery.git@2391c30d13c03ba778cdb58208aeb70040fbc9cf#egg=celery-origin/HEAD
chardet==2.0.1
colorama==0.2.5
command-not-found==0.3
-e git://github.com/SimonSapin/cssselect.git@f7b38ba6446d06ba3ed815729e65229532cd1818#egg=cssselect-origin/HEAD
defer==1.0.6
-e git://github.com/django-admin-bootstrapped/django-admin-bootstrapped.git@cbb567b85d0800ec9ed4da07004bde91d2a22e5a#egg=django_admin_bootstrapped-origin/master
-e git://github.com/davidfischer-ch/django-allauth.git@42ccb12701609b2b213e0c1128be374413678ff1#egg=django_allauth-origin/master
django-appconf==0.6
-e git://github.com/brack3t/django-braces.git@c4491e223ba56e22489ac26f4bc17d674eae34f2#egg=django_braces-origin/HEAD
-e git://github.com/davidfischer-ch/django-celery.git@1509614cdccedabb86217ee92677d495dbac1270#egg=django_celery-origin/dev
-e git://github.com/django-compressor/django-compressor.git@67f5de2cf503e2c375e5fe36f050b8dfa8cba145#egg=django_compressor-origin/develop
-e git://github.com/davidfischer-ch/django-crispy-forms.git@568b60cc8073740221f133390b2dd921c442da6b#egg=django_crispy_forms-origin/HEAD
-e git://github.com/morninj/django-email-obfuscator.git@02cee5f7bc0c3798ec2f4e154eb0c9aebcf2ae4f#egg=django_email_obfuscator-origin/master
-e git://github.com/django-extensions/django-extensions.git@f7b1bb51aba9a5b749e6964833b429faf948e74d#egg=django_extensions-dev
-e git://github.com/alex/django-filter.git@d88b98dd2b70551deb9c128b209fcf783b325acc#egg=django_filter-develop
-e git://github.com/evonove/django-oauth-toolkit.git@324cd9cd22833a038306f462a00f912b062f4519#egg=django_oauth_toolkit-origin/HEAD
django-phonenumber-field==0.5
-e git://github.com/davidfischer-ch/django-sendfile.git@7f79b124c6153a200116906a72110069f0eac268#egg=django_sendfile-dev
-e git://github.com/mbi/django-simple-captcha.git@47260b8b4c416bc5c5781e1724103d0c9c1cb4f6#egg=django_simple_captcha-origin/master
-e git://github.com/davidfischer-ch/django-rest-framework.git@b2e07d8613c289e14b2054e1e76837c29807595e#egg=djangorestframework-namespace
html5lib==0.999
-e git://github.com/celery/kombu.git@244b882e0c103b915e98de6ebb7d0cb026974515#egg=kombu-origin/HEAD
language-selector==0.1
lxml==3.3.5
mock==1.0.1
oauthlib==0.6.1
passlib==1.6.2
phonenumbers==6.1.0
psycopg2==2.5.3
pyaml==14.05.7
pycallgraph==1.0.1
pycurl==7.19.3
pygal==1.4.6
pygobject==3.12.0
pymongo==2.7.1
python-apt==0.9.3.5
python3-openid==3.0.4
pytoolbox==8.3.3-beta
pytz==2014.4
requests==2.2.1
requests-oauthlib==0.4.1
selenium==2.41.0
sendgrid==0.5.1
-e git://github.com/elbuo8/sendgrid-django.git@b026123f6dac27de9f67b95c2c9ef172bda53c2a#egg=sendgrid_django-origin/master
six==1.5.2
slumber==0.7.1.dev
smtpapi==0.1.2
-e git://github.com/davidfischer-ch/splinter.git@3d4924e1ac48b3e8968050246b0e77711f3f635c#egg=splinter-origin/HEAD
uWSGI==2.0.5.1
ufw==0.34-rc-0ubuntu2
unattended-upgrades==0.1
unittest2py3k==0.5.1
urllib3==1.7.1
-e git://github.com/alecthomas/voluptuous.git@0873a4d1f542997fcb6849fdfc0f68d66d7b7f18#egg=voluptuous-dev

Traceback:

Traceback (most recent call last):
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/utils/__init__.py", line 405, 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 "/home/ubuntu/cloudncode/venv/src/django/django/core/handlers/base.py", line 111, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/ubuntu/cloudncode/venv/src/django/django/views/generic/base.py", line 69, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/ubuntu/cloudncode/venv/src/django-braces/braces/views/_access.py", line 66, in dispatch
    request, *args, **kwargs)
  File "/home/ubuntu/cloudncode/venv/src/django/django/views/generic/base.py", line 87, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/ubuntu/cloudncode/venv/src/django/django/views/generic/edit.py", line 205, in post
    return super(BaseCreateView, self).post(request, *args, **kwargs)
  File "/home/ubuntu/cloudncode/venv/src/django/django/views/generic/edit.py", line 171, in post
    return self.form_valid(form)
  File "/home/ubuntu/cloudncode/venv/src/django/django/views/generic/edit.py", line 147, in form_valid
    self.object = form.save()
  File "/home/ubuntu/cloudncode/server/cloudncode_base/forms/encoding.py", line 42, in save
    instance.launch()
  File "/home/ubuntu/cloudncode/server/cloudncode_base/models/encoding.py", line 89, in launch
    tasks.EncodingTask().apply_async(kwargs={'task_pk': self.pk}, task_id=self.meta_id)
  File "/home/ubuntu/cloudncode/venv/src/celery/celery/app/task.py", line 462, in apply_async
    **dict(self._get_exec_options(), **options)
  File "/home/ubuntu/cloudncode/venv/src/celery/celery/app/base.py", line 383, in send_task
    amqp.send_task_message(P, name, message, **options)
  File "/home/ubuntu/cloudncode/venv/src/celery/celery/app/amqp.py", line 468, in publish_task
    **properties
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/messaging.py", line 168, in publish
    routing_key, mandatory, immediate, exchange, declare)
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/connection.py", line 436, in _ensured
    return fun(*args, **kwargs)
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/messaging.py", line 173, in _publish
    channel = self.channel
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/messaging.py", line 190, in _get_channel
    channel = self._channel = channel()
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/utils/__init__.py", line 407, in __call__
    value = self.__value__ = self.__contract__()
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/messaging.py", line 205, in <lambda>
    channel = ChannelPromise(lambda: connection.default_channel)
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/connection.py", line 756, in default_channel
    self.connection
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/connection.py", line 741, in connection
    self._connection = self._establish_connection()
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/connection.py", line 696, in _establish_connection
    conn = self.transport.establish_connection()
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/transport/pyamqp.py", line 112, in establish_connection
    conn = self.Connection(**opts)
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/connection.py", line 217, in __init__
    self.connect()
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/connection.py", line 236, in connect
    self.drain_events()
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/connection.py", line 354, in drain_events
    return self.blocking_read(timeout)
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/connection.py", line 359, in blocking_read
    return self.on_inbound_frame(read_frame())
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/method_framing.py", line 65, in frame_handler
    callback(channel, method_sig, buf, None)
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/connection.py", line 385, in on_inbound_method
    method_sig, payload, content,
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/abstract_channel.py", line 124, in dispatch_method
    args, _ = loads(amqp_method.args, payload, 4)
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/serialization.py", line 229, in loads
    val[key], offset = _read_item(buf, offset)
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/serialization.py", line 154, in _read_item
    ftype, type(ftype)))
amqp.exceptions.FrameSyntaxError: Unknown value in table: 70 (<class 'int'>)
ERROR Internal Server Error: /fr/encoding/task/create
Traceback (most recent call last):
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/utils/__init__.py", line 405, 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 "/home/ubuntu/cloudncode/venv/src/django/django/core/handlers/base.py", line 111, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/ubuntu/cloudncode/venv/src/django/django/views/generic/base.py", line 69, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/ubuntu/cloudncode/venv/src/django-braces/braces/views/_access.py", line 66, in dispatch
    request, *args, **kwargs)
  File "/home/ubuntu/cloudncode/venv/src/django/django/views/generic/base.py", line 87, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/ubuntu/cloudncode/venv/src/django/django/views/generic/edit.py", line 205, in post
    return super(BaseCreateView, self).post(request, *args, **kwargs)
  File "/home/ubuntu/cloudncode/venv/src/django/django/views/generic/edit.py", line 171, in post
    return self.form_valid(form)
  File "/home/ubuntu/cloudncode/venv/src/django/django/views/generic/edit.py", line 147, in form_valid
    self.object = form.save()
  File "/home/ubuntu/cloudncode/server/cloudncode_base/forms/encoding.py", line 42, in save
    instance.launch()
  File "/home/ubuntu/cloudncode/server/cloudncode_base/models/encoding.py", line 89, in launch
    tasks.EncodingTask().apply_async(kwargs={'task_pk': self.pk}, task_id=self.meta_id)
  File "/home/ubuntu/cloudncode/venv/src/celery/celery/app/task.py", line 462, in apply_async
    **dict(self._get_exec_options(), **options)
  File "/home/ubuntu/cloudncode/venv/src/celery/celery/app/base.py", line 383, in send_task
    amqp.send_task_message(P, name, message, **options)
  File "/home/ubuntu/cloudncode/venv/src/celery/celery/app/amqp.py", line 468, in publish_task
    **properties
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/messaging.py", line 168, in publish
    routing_key, mandatory, immediate, exchange, declare)
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/connection.py", line 436, in _ensured
    return fun(*args, **kwargs)
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/messaging.py", line 173, in _publish
    channel = self.channel
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/messaging.py", line 190, in _get_channel
    channel = self._channel = channel()
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/utils/__init__.py", line 407, in __call__
    value = self.__value__ = self.__contract__()
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/messaging.py", line 205, in <lambda>
    channel = ChannelPromise(lambda: connection.default_channel)
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/connection.py", line 756, in default_channel
    self.connection
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/connection.py", line 741, in connection
    self._connection = self._establish_connection()
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/connection.py", line 696, in _establish_connection
    conn = self.transport.establish_connection()
  File "/home/ubuntu/cloudncode/venv/src/kombu/kombu/transport/pyamqp.py", line 112, in establish_connection
    conn = self.Connection(**opts)
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/connection.py", line 217, in __init__
    self.connect()
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/connection.py", line 236, in connect
    self.drain_events()
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/connection.py", line 354, in drain_events
    return self.blocking_read(timeout)
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/connection.py", line 359, in blocking_read
    return self.on_inbound_frame(read_frame())
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/method_framing.py", line 65, in frame_handler
    callback(channel, method_sig, buf, None)
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/connection.py", line 385, in on_inbound_method
    method_sig, payload, content,
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/abstract_channel.py", line 124, in dispatch_method
    args, _ = loads(amqp_method.args, payload, 4)
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/serialization.py", line 229, in loads
    val[key], offset = _read_item(buf, offset)
  File "/home/ubuntu/cloudncode/venv/src/py-amqp/amqp/serialization.py", line 154, in _read_item
    ftype, type(ftype)))
amqp.exceptions.FrameSyntaxError: Unknown value in table: 70 (<class 'int'>)
@ask
Copy link
Contributor

ask commented Jun 10, 2014

Thanks! Is this the py-amqp master branch?

The bug is not in ChannelPromise, it will raise AttributeError there when the promise has not been evaluated, so the second exception is the real issue.

@davidfischer-ch
Copy link
Author

Indeed, I am still not used to read Python 3 traceback with raise from :-)

Here is the exact commit of py-ampq: -e git://github.com/celery/py-amqp.git@6b945b7065bd3bc53142e2d3f1d520d6f4a3d2de#egg=py-amqp.

I am also using a modified django-celery, but I do not think the issue is related to this.
Tested with djcelery 398fb4 and e92581ba.

@ask
Copy link
Contributor

ask commented Jun 20, 2014

It seems you are using amqp master? This is not yet stable, you should be using 1.4.x

@ask
Copy link
Contributor

ask commented Jul 31, 2014

Python 3 issue, we will be porting the development changes to py3 soon

@ask ask closed this as completed Jul 31, 2014
@cjerdonek
Copy link

I'm still seeing this in 3.0.33 (with aqmp 1.4.9). With this issue closed, is this being tracked?

@zoidyzoidzoid
Copy link

This was supposedly fixed in 3.0.15, I also just received it though. (amqp 1.4.9, kombu 3.0.33)

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/kombu/utils/__init__.py", line 423, in __call__
    return self.__value__
AttributeError: 'ChannelPromise' object has no attribute '__value__'

I'm not sure why, but it seems like the AttributeError isn't being caught here for some reason?

@fwachs
Copy link

fwachs commented Mar 23, 2016

Any news on this? I'm getting the same error. How should we procede?

@zoidyzoidzoid
Copy link

@fwachs: Can you make sure the code can actually connect to your Rabbit server, cuz it seems like I was actually getting this error somehow because of that?

@fwachs
Copy link

fwachs commented Mar 24, 2016

It's not connecting to the rabbit server actually. It doesn't matter what parameter I use, It will try to connect to localhost instead of the string I set.

@xavierp
Copy link

xavierp commented Apr 29, 2016

@fwachs Hello ! I'm getting the error too. It seems that it does not even try to connect and crashs before. Did you find any workaround ?
Thanks.

@tmehlinger
Copy link

I am also encountering this exception. I'd love to learn of a workaround.

@ask
Copy link
Contributor

ask commented May 26, 2016

Do you have the exact same traceback? What version of Python? The AttributeError is clearly being catched so that error message has nothing to do with the real error.

@ask ask reopened this May 26, 2016
@tmehlinger
Copy link

I actually tracked it down to not setting the AMQP host correctly when configuring Celery. I inherited a Django app with some code that looks something like this:

app = Celery('app_name', broker='amqp://')
class config:
    BROKER_URL = 'amqp://a_real_host:5672/'
app.config_from_object(config)

The broker URL from config wasn't overriding what was passed in to Celery (not sure whether this is desired behavior but it seems fine to me). Whenever some code would try to invoke a task, it would fail trying to connect to localhost.

To be clear--it was most certainly a problem in my own code, which I've since fixed. Hopefully this will help someone else.

@dpetzold
Copy link

@fwachs I also ran into this. The problem was that celery was not being initialized in the django app.

http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html

The celery client was trying to connect to amqp://127.0.0.1:5672 which caused the stacktrace similar to the one originally reported.

@ask ask added this to the v4.0 milestone Jul 8, 2016
@YetAnotherMinion
Copy link

YetAnotherMinion commented Aug 14, 2016

I run into this error when the broker is not yet online. I am running a worker, a master, and a rabbitmq broker in separate containers with docker-compose. If I put a sleep before the first time I call celery_instance.send_task in the master (basically waiting until the broker has fully started), then it connects fine. However if I take out the sleep, so that I begin trying to connect while the broker is still turning on, and the broker port has not been bound yet, then I see a similar stacktrace. Is the celery instance not being initialized correctly in the master, as dpetzold indicates? Because adding only a sleep of ~10 seconds before the call to send_task without changing any configuration or code makes it work, which makes me believe that I am configuring celery for my connection correctly.

In this case I would really like to inherit the default retry logic that my worker celery process seems to have:

http_worker_1 | [2016-08-14 20:49:57,786: ERROR/MainProcess] consumer: Cannot connect to amqp://myusername:**@rabbitmq:5672//: [Errno 111] Connection refused.
http_worker_1 | Trying again in 6.00 seconds...
http_worker_1 | 

I am running on alpine:3.4
Python 3.5.1
amqp==1.4.9
anyjson==0.3.3
billiard==3.3.0.23
celery==3.1.23
kombu==3.0.35
pytz==2016.6.1
requests==2.11.0

@billysan
Copy link

@tmehlinger you saved my day thanks! I now import the app object directly from MY celery.py that actually reads up the project's settings.py

@auvipy
Copy link
Member

auvipy commented Jan 13, 2018

can any of you send a fix or documentation improvement to avoid this error?

@auvipy auvipy modified the milestones: v4.0, 5.0 Jan 13, 2018
@phfilly
Copy link

phfilly commented Feb 16, 2018

+1

@bellkjn
Copy link

bellkjn commented Aug 8, 2018

In my case, mq was not running. After I execute it, the error message doesn't occur any more.

@atline
Copy link

atline commented Jun 4, 2019

Start rabbitmq-server fix my scenario.

@auvipy auvipy closed this as completed Jun 12, 2019
@ghost
Copy link

ghost commented Nov 4, 2019

In my case the problem was a container that was down

@auvipy auvipy removed this from the 5.0 milestone Nov 5, 2019
@johnyoonh
Copy link

johnyoonh commented Nov 29, 2019

It seems like it is back for 4.6.5 downgrading it 4.6.4 fixed it for me. Using celery==4.3.0

@auvipy
Copy link
Member

auvipy commented Nov 29, 2019

could you try https://github.com/celery/kombu/releases/tag/4.6.6 or master?

@gtangthousandeyes
Copy link

gtangthousandeyes commented Sep 16, 2020

hey guys, I know that this ticket is marked as Closed but I am at my wits end trying to solve this issue on my own. My current celery setup uses 3 machines: celery producer lives on server A, rabbitMQ server lives on B, and my celery workers on C. I am currently running into errors when my celery producers call task.delay() because it just hangs (so I will have to manually stop it from retrying). It looks like server A is having trouble connecting to server B when trying to enqueue a message and I cannot find any other online resources to help with this issue. Sorry if this is not the correct place to put this question.

I am using

  • RabbitMQ: 3.7.17
  • Celery: 4.3.0
  • Python: 3.6.7
  • OS: Ubuntu 18.04.3 LTS bionic

Here is my rabbitmq.config:

[
 {ssl, [{versions, ['tlsv1.2', 'tlsv1.1']}]},
 {rabbit,
  [
    {tcp_listeners, [{"127.0.0.1", 5672}]},
    {ssl_listeners, [5671]},
    {ssl_options, [{cacertfile, "/usr/local/share/ca-certificates/rootca.crt"},
                   {certfile, "/usr/local/share/ca-certificates/cert.crt"},
                   {keyfile, "/usr/local/share/private/key.key"},
                   {versions, ['tlsv1.2', 'tlsv1.1']},
                   {verify, verify_peer},
                   {fail_if_no_peer_cert, false}
                  ]},
    {auth_mechanisms, ['PLAIN', 'AMQPLAIN', 'EXTERNAL']}

  ]
 }
,{rabbitmq_management,
  [
   {listener, [{port, 15672},
               {ssl, true},
               {ssl_opts, [{cacertfile, "/usr/local/share/ca-certificates/rootca.crt"},
                           {certfile, "/usr/local/share/ca-certificates/cert.crt"},
                           {keyfile, "/usr/local/share/private/key.key"},
                           {versions, ['tlsv1.2', 'tlsv1.1']},
                           {verify, verify_peer},
                           {fail_if_no_peer_cert, false}]}
              ]}
  ]
 }
].

Here is the stacktrace

Traceback (most recent call last):
  File "/gtang/repo/lib/python3.6/site-packages/kombu/utils/functional.py", line 42, 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 "/gtang/repo/lib/python3.6/site-packages/amqp/transport.py", line 137, in _connect
    host, port, family, socket.SOCK_STREAM, SOL_TCP)
  File "/gtang/.pyenv/versions/3.6.7/lib/python3.6/socket.py", line 745, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -9] Address family for hostname not supported

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/gtang/repo/lib/python3.6/site-packages/kombu/utils/functional.py", line 343, in retry_over_time
    return fun(*args, **kwargs)
  File "/gtang/repo/lib/python3.6/site-packages/kombu/connection.py", line 275, in connect
    return self.connection
  File "/gtang/repo/lib/python3.6/site-packages/kombu/connection.py", line 823, in connection
    self._connection = self._establish_connection()
  File "/gtang/repo/lib/python3.6/site-packages/kombu/connection.py", line 778, in _establish_connection
    conn = self.transport.establish_connection()
  File "/gtang/repo/lib/python3.6/site-packages/kombu/transport/pyamqp.py", line 130, in establish_connection
    conn.connect()
  File "/gtang/repo/lib/python3.6/site-packages/amqp/connection.py", line 307, in connect
    self.transport.connect()
  File "/gtang/repo/lib/python3.6/site-packages/amqp/transport.py", line 77, in connect
    self._connect(self.host, self.port, self.connect_timeout)
  File "/gtang/repo/lib/python3.6/site-packages/amqp/transport.py", line 148, in _connect
    "failed to resolve broker hostname"))
  File "/gtang/repo/lib/python3.6/site-packages/amqp/transport.py", line 161, in _connect
    self.sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/gtang/repo/lib/python3.6/site-packages/celery/app/task.py", line 427, in delay
    return self.apply_async(args, kwargs)
  File "/gtang/repo/lib/python3.6/site-packages/celery_once/tasks.py", line 108, in apply_async
    return super(QueueOnce, self).apply_async(args, kwargs, **options)
  File "/gtang/repo/lib/python3.6/site-packages/celery/app/task.py", line 570, in apply_async
    **options
  File "/gtang/repo/lib/python3.6/site-packages/celery/app/base.py", line 756, in send_task
    amqp.send_task_message(P, name, message, **options)
  File "/gtang/repo/lib/python3.6/site-packages/celery/app/amqp.py", line 552, in send_task_message
    **properties
  File "/gtang/repo/lib/python3.6/site-packages/kombu/messaging.py", line 181, in publish
    exchange_name, declare,
  File "/gtang/repo/lib/python3.6/site-packages/kombu/connection.py", line 510, in _ensured
    return fun(*args, **kwargs)
  File "/gtang/repo/lib/python3.6/site-packages/kombu/messaging.py", line 187, in _publish
    channel = self.channel
  File "/gtang/repo/lib/python3.6/site-packages/kombu/messaging.py", line 209, in _get_channel
    channel = self._channel = channel()
  File "/gtang/repo/lib/python3.6/site-packages/kombu/utils/functional.py", line 44, in __call__
    value = self.__value__ = self.__contract__()
  File "/gtang/repo/lib/python3.6/site-packages/kombu/messaging.py", line 224, in <lambda>
    channel = ChannelPromise(lambda: connection.default_channel)
  File "/gtang/repo/lib/python3.6/site-packages/kombu/connection.py", line 852, in default_channel
    self.ensure_connection(**conn_opts)
  File "/gtang/repo/lib/python3.6/site-packages/kombu/connection.py", line 422, in ensure_connection
    callback, timeout=timeout)
  File "/gtang/repo/lib/python3.6/site-packages/kombu/utils/functional.py", line 357, in retry_over_time
    sleep(1.0)
KeyboardInterrupt

@thedrow
Copy link
Member

thedrow commented Sep 17, 2020

Please refer to StackOverflow or our mailing list.

@anistark
Copy link

anistark commented Oct 6, 2020

Hey @gtangthousandeyes, I'm facing same issue. Did you happen to resolve it?

Traceback (most recent call last):
  File "/.../venv/lib/python3.8/site-packages/kombu/utils/functional.py", line 43, 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 "/.../venv/lib/python3.8/site-packages/amqp/transport.py", line 137, in _connect
    entries = socket.getaddrinfo(
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

...

@anistark
Copy link

For me, reinstalled rabbitmq with newer version and it worked.

@zhao-weiqi
Copy link

i'm still getting this error.

celery==5.2.3
kombu==5.2.3

Anyone can help?

@jkozlowicz
Copy link

@zhao-weiqi
What helped me to resolve this on Mac was:
brew install rabbitmq
brew services start rabbitmq

@sorenwacker
Copy link

Is there a solution to this?

@ErikKalkoken
Copy link

I have a Django app with an integration test that runs multiple tasks in eager mode.

The test works perfectly in my local test environment when started with python manage.py test. But it fails with the above error when I try running it with tox.

The celery configuration is the same. If anybody has any ideas where I could start looking for a solution I would appreciate it.

@araujo88
Copy link

araujo88 commented Dec 1, 2022

In case any of you is having problem running this on a CI/CD pipeline with Python, I solved this by adding RabbitMQ as a service in my .yml file:

  services:
      - rabbitmq:latest
  variables:
    RABBITMQ_DEFAULT_USER: guest
    RABBITMQ_DEFAULT_PASS: guest
    AMQP_URL: 'amqp://guest:guest@rabbitmq:5672'

Hope this helps.

@celery celery deleted a comment from alanhamlett Dec 11, 2022
@shawjan
Copy link

shawjan commented Dec 29, 2022

it work well for me
kombu==5.1.0
celery==5.1.2

but work badly for me
kombu==5.3.2
celery==5.1.2

@wyhfrank
Copy link

wyhfrank commented Nov 18, 2023

For those who tried all the above solution but still getting the same error (espeically if you are using docker-compose). Maybe this will help you:

Check your environment variable setting for CELERY_BROKER_URL, for both the container of django and celery.

So the stupid mistake I made was that I only set this environment variable for the django container and forgot setting the one for the celery container in my docker-compose.yml file.
I was testing by setting it directly with the environment: field for the django service, then I decided to move it to a seperate .env file and reference it with env_file: .env for both django and celery services, which then solved the issue.
What a silly mistake..

@ybmeng
Copy link

ybmeng commented Mar 14, 2024

I made a stupid mistake in my __init__.py of changing

from .celery import app as celery_app

to

from celery import app as celery_app

and it caused this error. I had to play around a lot to find this cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests