diff --git a/lib/ruby_smb/client.rb b/lib/ruby_smb/client.rb index ebb35b728..9092fa5be 100644 --- a/lib/ruby_smb/client.rb +++ b/lib/ruby_smb/client.rb @@ -575,6 +575,9 @@ def recv_packet(encrypt: false) begin raw_response = dispatcher.recv_packet rescue RubySMB::Error::CommunicationError => e + # If raw_response is nil the connection is dead + raise EOFError if raw_response.nil? + if encrypt raise RubySMB::Error::EncryptionError, "Communication error with the "\ "remote host: #{e.message}. The server supports encryption but was "\