Celery与elasticsearch结果后端AuthenticationException

时间:2017-04-22 02:02:47

标签: elasticsearch celery

如何配置selery以使用官方elasticsearch docker图像提供的elasticsearch结果后端?

现在我收到了这个错误:

/usr/local/lib/python3.5/dist-packages/celery/app/trace.py:542: RuntimeWarning: Exception raised outside body: AuthenticationException(401, 'security_exception', {'status': 401, 'error': {'header': {'WWW-Authenticate': 'Basic realm="security" charset="UTF-8"'}, 'root_cause': [{'header': {'WWW-Authenticate': 'Basic realm="security" charset="UTF-8"'}, 'type': 'security_exception', 'reason': 'missing authentication token for REST request [/recognized_text/default_type]'}], 'type': 'security_exception', 'reason': 'missing authentication token for REST request [/recognized_text/default_type]'}}):
asr_1            | Traceback (most recent call last):
asr_1            |   File "/usr/local/lib/python3.5/dist-packages/celery/app/trace.py", line 427, in trace_task
asr_1            |     uuid, retval, task_request, publish_result,
asr_1            |   File "/usr/local/lib/python3.5/dist-packages/celery/backends/base.py", line 152, in mark_as_done
asr_1            |     self.store_result(task_id, result, state, request=request)
asr_1            |   File "/usr/local/lib/python3.5/dist-packages/celery/backends/base.py", line 309, in store_result
asr_1            |     request=request, **kwargs)
asr_1            |   File "/usr/local/lib/python3.5/dist-packages/celery/backends/base.py", line 652, in _store_result
asr_1            |     self.set(self.get_key_for_task(task_id), self.encode(meta))
asr_1            |   File "/usr/local/lib/python3.5/dist-packages/celery/backends/elasticsearch.py", line 80, in set
asr_1            |     datetime.utcnow().isoformat()[:-3]
asr_1            |   File "/usr/local/lib/python3.5/dist-packages/celery/backends/elasticsearch.py", line 95, in _index
asr_1            |     **kwargs
asr_1            |   File "/usr/local/lib/python3.5/dist-packages/elasticsearch/client/utils.py", line 73, in _wrapped
asr_1            |     return func(*args, params=params, **kwargs)
asr_1            |   File "/usr/local/lib/python3.5/dist-packages/elasticsearch/client/__init__.py", line 300, in index
asr_1            |     _make_path(index, doc_type, id), params=params, body=body)
asr_1            |   File "/usr/local/lib/python3.5/dist-packages/elasticsearch/transport.py", line 318, in perform_request
asr_1            |     status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
asr_1            |   File "/usr/local/lib/python3.5/dist-packages/elasticsearch/connection/http_urllib3.py", line 128, in perform_request
asr_1            |     self._raise_error(response.status, raw_data)
asr_1            |   File "/usr/local/lib/python3.5/dist-packages/elasticsearch/connection/base.py", line 124, in _raise_error
asr_1            |     raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
asr_1            | elasticsearch.exceptions.AuthenticationException: TransportError(401, 'security_exception', 'missing authentication token for REST request [/recognized_text/default_type]')

版本:

$ pip3 freeze
amqp==2.1.4
billiard==3.5.0.2
celery==4.0.2
elasticsearch==5.3.0
kombu==4.0.2
pytz==2017.2
requests==2.13.0
urllib3==1.20
vine==1.1.3

1 个答案:

答案 0 :(得分:1)

通过添加env xpack.security.enabled = false

解决