RabbitMQ 给出“访问被拒绝,用户登录被拒绝”的消息尝试遵循 celery 教程时出错

发布于 2024-08-14 18:45:34 字数 2990 浏览 2 评论 0原文

我正在尝试遵循 celery 教程,但遇到了问题当我运行 python manage.py celeryd 时:我的 RabbitMQ 服务器(安装在我的开发盒上的虚拟机上)不会让我的用户登录。

我在 Django 管理控制台上收到以下信息:

[ERROR/MainProcess] AMQP Listener: Connection Error: Socket closed. Trying again in 2 seconds...

这显示在 RabbitMQ 服务器上的 rabbit.log 文件中:

exception on TCP connection <0.5814.0> from $DJANGO_BOX_IP
{channel0_error,starting,{amqp,access_refused,"login refused for user '$CONFIGURED_USER'",'connection.start_ok'}}

我已经仔细检查了我的用户、权限和虚拟主机信息,它们全部看起来很匹配。非常感谢任何帮助排除故障。

更新:按照@asksol的建议,我得到以下回溯:

$MY_VIRTUAL_ENV/lib/python2.6/site-packages/carrot/connection.pyc in connection(self)
    118             return
    119         if not self._connection:
--> 120             self._connection = self._establish_connection()
    121             self._closed = False
    122         return self._connection

$MY_VIRTUAL_ENV/lib/python2.6/site-packages/carrot/connection.pyc in _establish_connection(self)
    131 
    132     def _establish_connection(self):
--> 133         return self.create_backend().establish_connection()
    134 
    135     def get_backend_cls(self):

$MY_VIRTUAL_ENV/lib/python2.6/site-packages/carrot/backends/pyamqplib.pyc in establish_connection(self)
    110                                insist=conninfo.insist,
    111                                ssl=conninfo.ssl,
--> 112                                connect_timeout=conninfo.connect_timeout)
    113 
    114     def close_connection(self, connection):

$MY_VIRTUAL_ENV/lib/python2.6/site-packages/amqplib/client_0_8/connection.pyc in __init__(self, host, userid, password, login_method, login_response, virtual_host, locale, client_properties, ssl, insist, connect_timeout, **kwargs)
    138                 self.wait(allowed_methods=[
    139                     (10, 20), # secure
--> 140                     (10, 30), # tune
    141                     ])
    142 

$MY_VIRTUAL_ENV/lib/python2.6/site-packages/amqplib/client_0_8/abstract_channel.pyc in wait(self, allowed_methods)
     88         method_sig, args, content = self.connection._wait_method(
---> 89             self.channel_id, allowed_methods)
     90 
     91         if content \

$MY_VIRTUAL_ENV/lib/python2.6/site-packages/amqplib/client_0_8/connection.pyc in _wait_method(self, channel_id, allowed_methods)
    196         while True:
    197             channel, method_sig, args, content = \
--> 198                 self.method_reader.read_method()
    199 
    200             if (channel == channel_id) \

$MY_VIRTUAL_ENV/lib/python2.6/site-packages/amqplib/client_0_8/method_framing.pyc in read_method(self)
    213         m = self.queue.get()
    214         if isinstance(m, Exception):
--> 215             raise m
    216         return m
    217 

IOError: Socket closed

I'm attempting to follow the celery tutorial, but I run into a problem when I run python manage.py celeryd: my RabbitMQ server (installed on a virtual machine on my dev box) won't let my user login.

I get the following on my Django management console:

[ERROR/MainProcess] AMQP Listener: Connection Error: Socket closed. Trying again in 2 seconds...

and this shows up in my rabbit.log file on my RabbitMQ server:

exception on TCP connection <0.5814.0> from $DJANGO_BOX_IP
{channel0_error,starting,{amqp,access_refused,"login refused for user '$CONFIGURED_USER'",'connection.start_ok'}}

I've double-checked my user, permissions, and vhost info, and they all seem to match up. Any help troubleshooting is greatly appreciated.

UPDATE: Following the advice of @asksol I get the following traceback:

$MY_VIRTUAL_ENV/lib/python2.6/site-packages/carrot/connection.pyc in connection(self)
    118             return
    119         if not self._connection:
--> 120             self._connection = self._establish_connection()
    121             self._closed = False
    122         return self._connection

$MY_VIRTUAL_ENV/lib/python2.6/site-packages/carrot/connection.pyc in _establish_connection(self)
    131 
    132     def _establish_connection(self):
--> 133         return self.create_backend().establish_connection()
    134 
    135     def get_backend_cls(self):

$MY_VIRTUAL_ENV/lib/python2.6/site-packages/carrot/backends/pyamqplib.pyc in establish_connection(self)
    110                                insist=conninfo.insist,
    111                                ssl=conninfo.ssl,
--> 112                                connect_timeout=conninfo.connect_timeout)
    113 
    114     def close_connection(self, connection):

$MY_VIRTUAL_ENV/lib/python2.6/site-packages/amqplib/client_0_8/connection.pyc in __init__(self, host, userid, password, login_method, login_response, virtual_host, locale, client_properties, ssl, insist, connect_timeout, **kwargs)
    138                 self.wait(allowed_methods=[
    139                     (10, 20), # secure
--> 140                     (10, 30), # tune
    141                     ])
    142 

$MY_VIRTUAL_ENV/lib/python2.6/site-packages/amqplib/client_0_8/abstract_channel.pyc in wait(self, allowed_methods)
     88         method_sig, args, content = self.connection._wait_method(
---> 89             self.channel_id, allowed_methods)
     90 
     91         if content \

$MY_VIRTUAL_ENV/lib/python2.6/site-packages/amqplib/client_0_8/connection.pyc in _wait_method(self, channel_id, allowed_methods)
    196         while True:
    197             channel, method_sig, args, content = \
--> 198                 self.method_reader.read_method()
    199 
    200             if (channel == channel_id) \

$MY_VIRTUAL_ENV/lib/python2.6/site-packages/amqplib/client_0_8/method_framing.pyc in read_method(self)
    213         m = self.queue.get()
    214         if isinstance(m, Exception):
--> 215             raise m
    216         return m
    217 

IOError: Socket closed

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤檠 2024-08-21 18:45:34

你正在运行 django 吗?
如果是这样,那么试试这个:

>>> from carrot.connection import DjangoBrokerConnection
>>> c = DjangoBrokerConnection()
>>> c.connection

它会给出同样的结果吗?
您确定连接到正确的主机名,并且用户名和密码可以访问虚拟主机吗?

更新:

>>> from carrot.connection import DjangoBrokerConnection
>>> c = DjangoBrokerConnection()
>>> for n in ("host", "userid", "password", "virtual_host", "ssl"):
...     print("%s -> %s" % (n, repr(getattr(c, n, None))))

更新:您必须在运行 c.connection 之前执行上述操作,因为连接是在胡萝卜中延迟建立的。

Are you running django?
If so, then try this:

>>> from carrot.connection import DjangoBrokerConnection
>>> c = DjangoBrokerConnection()
>>> c.connection

Does it give the same thing?
Are you sure you're connecting to the right hostname, and that the username and password has access to the virtual host?

UPDATE:

>>> from carrot.connection import DjangoBrokerConnection
>>> c = DjangoBrokerConnection()
>>> for n in ("host", "userid", "password", "virtual_host", "ssl"):
...     print("%s -> %s" % (n, repr(getattr(c, n, None))))

UPDATE: You have to do the above before running c.connection, as the connection is established lazily in carrot.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文