杂谈1-解决套接字读取错误

杂谈1-解决套接字读取错误_第1张图片

解决方法

这个错误信息表明在系统中从套接字读取数据时出现了问题。错误代码10022可能表示提供了无效的参数。消息似乎是用中文写的,大致翻译为“字符没有连接”。

为了解决此问题,您应该检查向套接字提供的参数,以确保它们是有效和正确的。此外,检查系统日志以获取有关错误的更详细信息,可以帮助识别错误的根本原因。

参考链接python - How to add retry for celery backend connection? - Stack Overflow

Exception: Error while reading from socket: (104, 'Connection reset by peer')
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/redis/connection.py", line 198, in _read_from_socket
    data = recv(self._sock, socket_read_size)
  File "/usr/local/lib/python3.7/dist-packages/redis/_compat.py", line 72, in recv
    return sock.recv(*args, **kwargs)
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/celery/app/trace.py", line 477, in trace_task
    uuid, retval, task_request, publish_result,
  File "/usr/local/lib/python3.7/dist-packages/celery/backends/base.py", line 154, in mark_as_done
    self.store_result(task_id, result, state, request=request)
  File "/usr/local/lib/python3.7/dist-packages/celery/backends/base.py", line 439, in store_result
    request=request, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/celery/backends/base.py", line 855, in _store_result
    current_meta = self._get_task_meta_for(task_id)
  File "/usr/local/lib/python3.7/dist-packages/celery/backends/base.py", line 873, in _get_task_meta_for
    meta = self.get(self.get_key_for_task(task_id))
  File "/usr/local/lib/python3.7/dist-packages/celery/backends/redis.py", line 346, in get
    return self.client.get(key)
  File "/usr/local/lib/python3.7/dist-packages/redis/client.py", line 1606, in get
    return self.execute_command('GET', name)
  File "/usr/local/lib/python3.7/dist-packages/redis/client.py", line 901, in execute_command
    return self.parse_response(conn, command_name, **options)
  File "/usr/local/lib/python3.7/dist-packages/redis/client.py", line 915, in parse_response
    response = connection.read_response()
  File "/usr/local/lib/python3.7/dist-packages/redis/connection.py", line 739, in read_response
    response = self._parser.read_response()
  File "/usr/local/lib/python3.7/dist-packages/redis/connection.py", line 324, in read_response
    raw = self._buffer.readline()
  File "/usr/local/lib/python3.7/dist-packages/redis/connection.py", line 256, in readline
    self._read_from_socket()
  File "/usr/local/lib/python3.7/dist-packages/redis/connection.py", line 223, in _read_from_socket
    (ex.args,))
redis.exceptions.ConnectionError: Error while reading from socket: (104, 'Connection reset by peer')


Celery worker: None
Celery task id: 244b56af-7c96-56cf-a01a-9256cfd98ade
Celery retry attempt: 0
Task args: []
Task kwargs: {'address': 'ipadd', 'uid': 'uid', 'hexID': 'hexID', 'taskID': '244b56af-7c96-56cf-a01a-9256cfd98ade'}

I am using celery 5.0.1 and using CELERY_BACKEND_URL as redis://:password@redisinstance1:6379/0. It works fine, but when there is a Redis instance loose connection, it breaks out tasks with an error.

When I run the second tasks, it works fine, there is some glitch in the connection for a short period of time.

Can I set something by which, when celery tries to update the results to Redis, if it returns an error, it will retry after 2-5 seconds?

I know how to set retry in the task, but this does not task failure. My tasks work fine and it returns the data, but celery is losing connection while updating to the backend.

你可能感兴趣的:(客户,python,java,开发语言)