smbclient: Broken Pipe error when python kernel sits too long
See original GitHub issueFirstly, thanks for writing this module. I’ve been able to get it to connect to our windows shares to open and find files from a JupyterLab environment.
The issue I’ve having is that if I let my python kernel sit for a bit (>10 minutes or so), I will get a [Errno 32] Broken Pipe error when I try to use smbclient.open_file
or smbclient.listdir
. I tried to use the smbclient.reset_connection_cache()
function to fix it but also got the broken pipe error. I was able to resolve this by restarting the python kernel. I’m guessing that my connection to the server is being disconnected, but I would expect that there could be a way to re-connect without restarting the kernel or throwing an error. Thoughts?
System Information: Environment: JupyterHub (TLJH) /JupyterLab V1.1.3 running on an Ubuntu 18 server Python: 3.6
Here are details of the error from the listdir command:
`--------------------------------------------------------------------------- BrokenPipeError Traceback (most recent call last) <ipython-input-14-aeb8318e4032> in <module> ----> 1 smbclient.listdir(r"\servername\removed")
/opt/tljh/user/lib/python3.6/site-packages/smbclient/_os.py in listdir(path, search_pattern, **kwargs) 218 :return: A list containing the names of the entries in the directory. 219 “”" –> 220 with SMBDirectoryIO(path, mode=‘r’, share_access=‘r’, **kwargs) as dir_fd: 221 try: 222 raw_filenames = dir_fd.query_directory(search_pattern, FileInformationClass.FILE_NAMES_INFORMATION)
/opt/tljh/user/lib/python3.6/site-packages/smbclient/_io.py in enter(self) 292 293 def enter(self): –> 294 self.open() 295 return self 296
/opt/tljh/user/lib/python3.6/site-packages/smbclient/_io.py in open(self, transaction) 338 create_disposition, 339 self._create_options, –> 340 send=(transaction is None), 341 ) 342 except SMBResponseException as exc:
/opt/tljh/user/lib/python3.6/site-packages/smbprotocol/open.py in create(self, impersonation_level, desired_access, file_attributes, share_access, create_disposition, create_options, create_contexts, oplock_level, send) 1208 request = self.connection.send(create, 1209 self.tree_connect.session.session_id, -> 1210 self.tree_connect.tree_connect_id) 1211 return self._create_response(request) 1212
/opt/tljh/user/lib/python3.6/site-packages/smbprotocol/connection.py in send(self, message, sid, tid, credit_request, message_id, async_id) 964 “”" 965 return self._send([message], session_id=sid, tree_id=tid, message_id=message_id, credit_request=credit_request, –> 966 async_id=async_id)[0] 967 968 def send_compound(self, messages, sid, tid, related=False):
/opt/tljh/user/lib/python3.6/site-packages/smbprotocol/connection.py in wrapped(self, *args, **kwargs) 761 def wrapped(self, *args, **kwargs): 762 self._check_worker_running() –> 763 return func(self, *args, **kwargs) 764 return wrapped 765
/opt/tljh/user/lib/python3.6/site-packages/smbprotocol/connection.py in _send(self, messages, session_id, tree_id, message_id, credit_request, related, async_id) 1242 send_data = self._encrypt(send_data, session) 1243 -> 1244 self.transport.send(send_data) 1245 return requests 1246
/opt/tljh/user/lib/python3.6/site-packages/smbprotocol/transport.py in wrapped(self, *args, **kwargs) 65 self._connected = True 66 —> 67 func(self, *args, **kwargs) 68 69 return wrapped
/opt/tljh/user/lib/python3.6/site-packages/smbprotocol/transport.py in send(self, header) 106 data = tcp_packet.pack() 107 while data: –> 108 sent = self._sock.send(data) 109 data = data[sent:] 110
BrokenPipeError: [Errno 32] Broken pipe`
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (3 by maintainers)
Top GitHub Comments
Sorry for the delay on looking into this one. I believe I’ve fixed the main part of this bug with https://github.com/jborean93/smbprotocol/pull/50. I’ve tested it in a few different scenarios and I no longer can reproduce the Broken pipe error from before. There may still be problems that I haven’t encountered in the future but that should be tracked in a different issue. For now I consider this bug fixed and will be in the 1.2.0 release of smbprotocol.
Thanks for the confirmation, I will have to play around with this a bit and find a solution. I can’t guarantee I will get to it straight away but will try my best.