Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SFTPStorage doesn't reconnect after ssh connection is closed #563

Closed
mnacharov opened this issue Aug 22, 2018 · 3 comments · Fixed by #564
Closed

SFTPStorage doesn't reconnect after ssh connection is closed #563

mnacharov opened this issue Aug 22, 2018 · 3 comments · Fixed by #564

Comments

@mnacharov
Copy link
Contributor

We faced with this issue in one of our projects.
After storage server reboots celery workers tries to save files using socket to ssh-connection which have been closed.
I want to add reconnect logic in this class (I will send a PR)

Traceback (most recent call last):
  File "/app/python/lib/python3.6/site-packages/celery/app/trace.py", line 374, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/app/python/lib/python3.6/site-packages/celery/app/trace.py", line 629, in __protected_call__
    return self.run(*args, **kwargs)
  File "/app/project/demo_app/tasks.py", line 20, in check_storage_task
    text = obj.data.read().decode()
  File "/app/python/lib/python3.6/site-packages/storages/backends/sftpstorage.py", line 217, in read
    self.file = self._storage._read(self._name)
  File "/app/python/lib/python3.6/site-packages/storages/backends/sftpstorage.py", line 104, in _read
    return self.sftp.open(remote_path, 'rb')
  File "/app/python/lib/python3.6/site-packages/paramiko/sftp_client.py", line 327, in open
    t, msg = self._request(CMD_OPEN, filename, imode, attrblock)
  File "/app/python/lib/python3.6/site-packages/paramiko/sftp_client.py", line 729, in _request
    num = self._async_request(type(None), t, *arg)
  File "/app/python/lib/python3.6/site-packages/paramiko/sftp_client.py", line 754, in _async_request
    self._send_packet(t, msg)
  File "/app/python/lib/python3.6/site-packages/paramiko/sftp.py", line 170, in _send_packet
    self._write_all(out)
  File "/app/python/lib/python3.6/site-packages/paramiko/sftp.py", line 133, in _write_all
    n = self.sock.send(out)
  File "/app/python/lib/python3.6/site-packages/paramiko/channel.py", line 767, in send
    return self._send(s, m)
  File "/app/python/lib/python3.6/site-packages/paramiko/channel.py", line 1133, in _send
    raise socket.error('Socket is closed')
OSError: Socket is closed
@mnacharov
Copy link
Contributor Author

@jschneier
Hi!
Is there some plans for releasing this bugfix in next minor version 1.7.2 ?
it's not so pretty to have a link to github in our requirements file

@jschneier
Copy link
Owner

I believe this made it into 1.7.1?

@mnacharov
Copy link
Contributor Author

Yep! Sorry, my bad..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants