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

[16.0] fs_storage + EDI: connection closed after some time #319

Closed
JordiMForgeFlow opened this issue Jan 12, 2024 · 5 comments · Fixed by #320
Closed

[16.0] fs_storage + EDI: connection closed after some time #319

JordiMForgeFlow opened this issue Jan 12, 2024 · 5 comments · Fixed by #320
Labels
bug Something isn't working

Comments

@JordiMForgeFlow
Copy link
Contributor

Module

fs_storage

Describe the bug

I am using fs_storage to connect to SFTP with EDI (the PR is still not merged OCA/edi-framework#26). The connection works fine, but after some time the EDI jobs start to fail due to the following issue:

File "/opt/odoo/auto/addons/fs_storage/models/fs_storage.py", line 376, in add
    self.fs.makedirs(self.fs.sep.join(path))
  File "/usr/local/lib/python3.10/site-packages/fsspec/implementations/sftp.py", line 89, in makedirs
    self.ftp.mkdir(new_path, mode)
  File "/usr/local/lib/python3.10/site-packages/paramiko/sftp_client.py", line 460, in mkdir
    self._request(CMD_MKDIR, path, attr)
  File "/usr/local/lib/python3.10/site-packages/paramiko/sftp_client.py", line 856, in _request
    num = self._async_request(type(None), t, *args)
  File "/usr/local/lib/python3.10/site-packages/paramiko/sftp_client.py", line 881, in _async_request
    self._send_packet(t, msg)
  File "/usr/local/lib/python3.10/site-packages/paramiko/sftp.py", line 209, in _send_packet
    self._write_all(out)
  File "/usr/local/lib/python3.10/site-packages/paramiko/sftp.py", line 173, in _write_all
    n = self.sock.send(out)
  File "/usr/local/lib/python3.10/site-packages/paramiko/channel.py", line 799, in send
    return self._send(s, m)
  File "/usr/local/lib/python3.10/site-packages/paramiko/channel.py", line 1196, in _send
    raise socket.error("Socket is closed")
OSError: Socket is closed

If I press the button 'TEST CONNECTION' in the fs storage, I also get the same error. However, if I restart Odoo, it starts working fine again.

My hint is that the problem comes from fs_storage storing the connection in a variable (

self.__fs = self._get_filesystem()
). The connection closes at some point (probably due to timeout) and it does not work anymore.

@lmignon @sebastienbeau have you faced something like this with fs_storage?

@JordiMForgeFlow JordiMForgeFlow added the bug Something isn't working label Jan 12, 2024
@lmignon
Copy link
Contributor

lmignon commented Jan 12, 2024

@JordiMForgeFlow I never encountered this kind of error. You could patch the code to not store the filesystem objet on a variable to see if it solve the problem...

@JordiMForgeFlow
Copy link
Contributor Author

@lmignon thanks for the feedback. I will try and let you know the outcome

@nilshamerlinck
Copy link
Contributor

Hello @JordiMForgeFlow I faced a similar issue where the underlying ssh connection seems to be prematurely closed. Adding a timeout helped as a workaround. Can you try adding { "timeout": 2 }in your fs.storage options?

@JordiMForgeFlow
Copy link
Contributor Author

Hello @JordiMForgeFlow I faced a similar issue where the underlying ssh connection seems to be prematurely closed. Adding a timeout helped as a workaround. Can you try adding { "timeout": 2 }in your fs.storage options?

Thank you for the hint @nilshamerlinck, I will give it a try and see if that solves it

@JordiMForgeFlow
Copy link
Contributor Author

@nilshamerlinck @lmignon After trying different things I have managed to get it working with the following changes: #320

I have suggested them as settings in the FS Storage.

Apart from storing the connection, I also saw that fsspec instances also cache information. Invalidating the cache when the connection gives an error allowed to only force the reconnection when needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants