无法让皮拉比特运行

2024-04-29 18:59:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在做一个用python运行rabbitmq的小项目,我需要一种方法来访问管理api并获取统计数据、作业等。我尝试过使用pyRabbit,但似乎没有不确定为什么工作,希望更好的程序员可能知道?下面我只是按照基本教程和自述来执行非常基本的任务。我的服务器启动了,我可以在python和pyrabbit之外连接。我已经安装了依赖关系没有运气,至少我认为。另外,对于获取pyRabbit之外的队列大小、队列、活动客户端等,也可以提出其他建议。在

'Microsoft Windows[版本6.1.7601]

版权所有(c)2009 Microsoft Corporation。版权所有。在

C:\Users\user>;python

Python2.7.3(默认值,2012年4月10日,23:31:26)[MSCV.1500 32位(Intel)]在win32上

键入“帮助”、“版权”、“信用证”或“许可证”以获取更多信息。在

进口鼻

导入httplib2

导入模拟

从皮拉比特.api导入客户端

进口pyrabbit

cl=客户('我的ip.com:15672'客人','客人','客人')

在你还活着()

无法解码JSON对象-(找不到。)()

回溯(最近一次呼叫):

文件“”,第1行,输入

文件“C:\Python27\lib\site packages\pyrabbit\api.py文件,第48行,在包装器if中self.拥有管理权限公司名称:

文件“C:\Python27\lib\site packages\pyrabbit\api.py文件“,第175行,在has_admin_right whoami=自我。去吧()

文件“C:\Python27\lib\site packages\pyrabbit\api.py文件“,第161行,在get_whoami whoami=self.http.do\u调用(路径,“GET”)

文件“C:\Python27\lib\site packages\pyrabbit\http.py“,第112行,在do\u call raise HTTPError(content,责任状态, 责任原因,路径,主体) pyrabbit.http.HTTPError:404-找不到对象(None)(whoami)(None)'


Tags: 文件pyapihttp客户端队列libpackages
2条回答

这可能是一个rabbitmq配置问题:如本文所述:https://www.rabbitmq.com/access-control.html“guest”用户只能通过localhost进行连接:

By default, the guest user is prohibited from connecting to the broker remotely; it can only connect over a loopback interface (i.e. localhost). This applies both to AMQP and to any other protocols enabled via plugins. Any other users you create will not (by default) be restricted in this way.

This is configured via the loopback_users item in the configuration file.

If you wish to allow the guest user to connect from a remote host, you should set the loopback_users configuration item to []. A complete >rabbitmq.config which does this would look like:

[{rabbit, [{loopback_users, []}]}].

我从来没能解决这个问题。但是,这迫使我了解了json是什么,我使用了simplejson和httplib2,它工作起来很有魅力。。。在

相关问题 更多 >