简体   繁体   English

在Heroku上安装Celery时出现“ [[Errno 111]连接被拒绝”错误

[英]Get “[Errno 111] Connection refused” error when mount Celery on Heroku

I was trying to use Celery to write a backend asynchronous process for my Django project. 我试图使用Celery为Django项目编写后端异步过程。 I use Rabbitmq as my task queue while using Cloudamqp with Heroku. 我将Rabbitamq用作我的任务队列,同时将Cloudamqp与Heroku一起使用。
The problem is: the whole project works perfectly on my own laptop(using localhost to test),while it didn't work on the production server. 问题是:整个项目可以在我自己的笔记本电脑上完美运行(使用localhost进行测试),而不能在生产服务器上运行。

This is the error message I got: [Errno 111] Connection refused 这是我收到的错误消息: [Errno 111] Connection refused

Then I did some research, I might be wrong but it seems that the problem is I already reached the limitation of number of worker can be used since i am using a free account for Heroku right now. 然后我做了一些研究,我可能是错的,但是问题似乎是我已经达到可以使用工作人员数量的限制,因为我现在正在为Heroku使用免费帐户。
I read about this:"But remember to tweak the BROKER_POOL_LIMIT if you're using the free plan. Set it to 1 and you should be good. If you have connection problems, try reduce the concurrency of both your web workers and in the celery worker." 我读到以下内容:“但是请记住,如果您使用的是免费计划,请调整BROKER_POOL_LIMIT。将其设置为1,就可以了。如果您遇到连接问题,请尝试减少网络工作者和celery的并发性工人。” but I am not sure how to do that. 但我不确定该怎么做。

Here is my setting.py: 这是我的setting.py:

    BROKER_URL="amqp://paswzaog:0TwC3i7cBdTAKA9JE57EMm1xUzovFbry@turtle.rmq.cloudamqp.com/paswzaog"
    BROKER_POOL_LIMIT = 1
    CELERY_ACCEPT_CONTENT = ['json']
    CELERY_TASK_SERIALIZER = 'json'
    CELERY_RESULT_SERIALIZER = 'json'
    CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend'
    CELERY_BEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
    CELERY_RESULT_BACKEND = 'amqp'
    CELERY_TASK_RESULT_EXPIRES = 18000  # 5 hours.`

Here is the error message: 这是错误消息:

'[Errno 111] Connection refused
'/app/.heroku/python/bin',
'/app/.heroku/python/lib/python2.7/site-packages/setuptools-3.6-py2.7.egg',
'/app/.heroku/python/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg',
'/app',
'/app/.heroku/python/lib/python27.zip',
'/app/.heroku/python/lib/python2.7',
'/app/.heroku/python/lib/python2.7/plat-linux2',
'/app/.heroku/python/lib/python2.7/lib-tk',
'/app/.heroku/python/lib/python2.7/lib-old',
'/app/.heroku/python/lib/python2.7/lib-dynload',
'/app/.heroku/python/lib/python2.7/site-packages',
'/app','

Did anybody has a similar problem before? 以前有人遇到过类似的问题吗? or can someone recommend a thorough tutorial about how to do setting up stuff of Celery onto Heroku? 还是有人可以推荐有关如何在Heroku上设置Celery的详细教程? Thanks in advance! 提前致谢!

It looks like your credentials might not be valid. 您的凭据似乎无效。 Either that or you have more than 1 concurrent connection. 或者,或者您有多个并发连接。

A good way to test this would be to scale your web servers to 0 (heroku scale web=0), then create a single worker (heroku scale worker=1) -- then tail your Heroku logs (heroku logs --tail) to see if your single worker can connect. 一个很好的测试方法是将您的Web服务器扩展到0(heroku scale web = 0),然后创建一个工作程序(heroku scale worker = 1)–然后将您的Heroku日志(heroku logs --tail)尾随看看您的单工是否可以连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM