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

Customizable receive timeout for SMB Connection #285

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/smbprotocol/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,9 @@ def __init__(self, guid, server_name, port=445, require_signing=True):
self.port = port
self.transport = None # Instanciated in .connect()

# Experimental customizable value. Might be removed in the future
self._receive_timeout = int(os.environ.get("SMB_EXPERIMENTAL_TRANSPORT_RECEIVE_TIMEOUT", 600))

# Table of Session entries, the order is important for smbclient.
self.session_table = OrderedDict()

Expand Down Expand Up @@ -1306,7 +1309,7 @@ def _process_message_thread(self):
# safe choice.
# https://github.com/jborean93/smbprotocol/issues/31
try:
b_msg = self.transport.recv(600)
b_msg = self.transport.recv(self._receive_timeout)
except TimeoutError as ex:
# Check if the connection has unanswered keepalive echo requests with the reserved field set.
# When unanswered keep alive echo exists, the server did not respond withing two times the timeout.
Expand Down
Loading