I have configured my celery.py as its documents but I put my celery broker url to AWS SQS but I cannot start it to work. When I run the celery worker, I get the ValueError as:
File "/Users/abd/Desktop/proj-aws/lib/python3.6/site-packages/celery/bin/base.py", line 244, in __call__ ret = self.run(*args, **kwargs) File "/Users/abd/Desktop/proj-aws/lib/python3.6/site-packages/celery/bin/worker.py", line 255, in run **kwargs) File "/Users/abd/Desktop/proj-aws/lib/python3.6/site-packages/celery/worker/worker.py", line 99, in __init__ self.setup_instance(**self.prepare_args(**kwargs)) File "/Users/abd/Desktop/proj-aws/lib/python3.6/site-packages/celery/worker/worker.py", line 120, in setup_instance self._conninfo = self.app.connection_for_read() File "/Users/abd/Desktop/proj-aws/lib/python3.6/site-packages/celery/app/base.py", line 752, in connection_for_read return self._connection(url or self.conf.broker_read_url, **kwargs) File "/Users/abd/Desktop/proj-aws/lib/python3.6/site-packages/celery/app/base.py", line 828, in _connection 'broker_connection_timeout', connect_timeout File "/Users/abd/Desktop/proj-aws/lib/python3.6/site-packages/kombu/connection.py", line 181, in __init__ url_params = parse_url(hostname) File "/Users/abd/Desktop/proj-aws/lib/python3.6/site-packages/kombu/utils/url.py", line 34, in parse_url scheme, host, port, user, password, path, query = _parse_url(url) File "/Users/abd/Desktop/proj-aws/lib/python3.6/site-packages/kombu/utils/url.py", line 52, in url_to_parts parts.port, File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/parse.py", line 167, in port port = int(port, 10) ValueError: invalid literal for int() with base 10: 'xi'
I've been looking around but seems to have no clue how to fix this. Please help me out with this! Much appreciated!
I encountered the same problem, and resolved it.
First check (it's very likely) that your AWS access key ID or secret key contains 'xi/' somewhere, and that you have:
BROKER_URL = "sqs://%s:%s@" % (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
If so, then your problem is in URL unsafe keys, and the fix is:
BROKER_URL = 'sqs://{0}:{1}@'.format(
urllib.parse.quote(AWS_ACCESS_KEY_ID, safe=''),
urllib.parse.quote(AWS_SECRET_ACCESS_KEY, safe='')
)
Note: Use urllib.quote if using Python 2.x
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With