question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

smbclient: Broken Pipe error when python kernel sits too long

See original GitHub issue

Firstly, 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:closed
  • Created 4 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
jborean93commented, Sep 22, 2020

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.

2reactions
jborean93commented, Jan 23, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to handle broken pipe error in python? (socket ...
The fix is to align the expectations of the server with what the client is actually doing, i.e. either don't expect the client...
Read more >
DArtagan - Profile - Bountysource
DArtagan commented on this issuesmbclient: Broken Pipe error when python kernel sits too long. smbprotocol 2 years ago.
Read more >
Samba 3.0.21 Available for Download
Added "volume" command to smbclient that prints out the volume name and serial number. * Added "fix for broken SMB_INFO_VOLUME level used by...
Read more >
Nrw - River Thames Conditions - Environment Agency - GOV.UK
#Foioase How much to ship 100 lbs usps, Stony brook university tuition due date, ... Long ago and today transportation, Smoking a crack...
Read more >
other.xml.gz - Linux @ CERN
Log dev name now returned to kernel for registering during cmirror CTR. ... Apply patch for python modules loading (fixes #489109) - use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found