django ConnectionError: Error 104 while writing to socket. Connection reset by peer

created at 07-17-2021 views: 1

django ConnectionError: Error 104 while writing to socket Connection reset by peer:

Internal Server Error: /api/v2/chenxm/
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/chenxinming/StructureSearchViews/views.py", line 27, in post
    data = self.run(obj_keys, concept_name, startPos, endPos)
  File "/home/chenxinming/StructureSearch/structureSearch.py", line 546, in run
    data = self.getObjectData(union_obj_keys, type)
  File "/home/chenxinming/StructureSearch/structureSearch.py", line 462, in getObjectData
    concept_map = Object.bulkGetObjectConcept(obj_keys)
  File "/home/chenxinming/object.py", line 868, in bulkGetObjectConcept
    concept_li = p.execute()
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 2894, in execute
    return execute(conn, stack, raise_on_error)
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 2810, in _execute_pipeline
    connection.send_packed_command(all_cmds)
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 603, in send_packed_command
    (errno, errmsg))
ConnectionError: Error 104 while writing to socket. Connection reset by peer.

After inspection and investigation, it was found that the amount of data obtained by redis was too large, which caused redis to interrupt the connection.

with cache.pipeline(transaction=False) as p:
    for english_name in english_li:
        p.hget(keyName._getConceptNameTable(), english_name)
    concept_li = p.execu

The reason is that when using the pipeline, the length of english_li exceeds 10w. Modify the number of lengths to limit english_li.

Please log in to leave a comment.