miketeo / pysmb

pysmb is an experimental SMB/CIFS library written in Python. It implements the client-side SMB/CIFS protocol (SMB1 and SMB2) which allows your Python application to access and transfer files to/from SMB/CIFS shared folders like your Windows file sharing and Samba folders.
Other
338 stars 95 forks source link

urllib2.URLError: <urlopen error smb error: [Errno 10054] An existing connection was forcibly closed by the remote host> #29

Open vasujammula opened 9 years ago

vasujammula commented 9 years ago

While opening a file using urllib got this error

vasujammula commented 9 years ago

File "C:\Python27\lib\urllib2.py", line 400, in open response = self._open(req, data) File "C:\Python27\lib\urllib2.py", line 418, in _open '_open', req) File "C:\Python27\lib\urllib2.py", line 378, in _call_chain result = func(*args) File "build\bdist.win32\egg\smb\SMBHandler.py", line 63, in smb_open File "build\bdist.win32\egg\smb\SMBConnection.py", line 112, in connect File "build\bdist.win32\egg\smb\SMBConnection.py", line 511, in _pollForNetBIO SPacket

miketeo commented 9 years ago

Please check if you have the remote server name correct. In most of the cases when the remote server terminates the connection, the app has used the wrong Windows name for the remote server.

AgrimPrasad commented 9 years ago

Probably, the remote server's NetBIOS port (port 137) is closed. This may be the case if SMB has been implemented directly over TCP/IP on port 445, rather than by using NetBIOS. An example of this might be a Samba server.

You can verify this by opening Wireshark and inspecting traffic for the remote server you are trying to connect to (Filter: ip.dst==xxx.xxx.xxx.xxx || ip.src==xxx.xxx.xxx.xxx)

ghost commented 6 years ago

Try "is_direct_tcp=True" and "port=445". It worked for me on a 2012 server out of my domain.

DjesLoc commented 3 years ago

even with is_direct_tcp=True" and "port=445" i still get this error.

File "SMBConnection.py", line 597, in _pollForNetBIOSPacket d = self.sock.recv(read_len) socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host

Remote server is a WIN CE embedded PC. Storing a file bigger than 4KB doesn't work.

Server name and client machine name seems correct.

DjesLoc commented 3 years ago

I did some further tests and discovered that it disconnects (socket.error: [Errno 10054]) when a file is bigger then 65520 bytes. Is there a problem with packet sizes?

DjesLoc commented 3 years ago

Further analyses: is_signing_active is False max_buffer_size and max_raw_size are 65520 Bytes

Packetsize is bigger then 65520 Bytes thats the reason why the sambaserver disconnects.

How to solve?

miketeo commented 3 years ago

Please do not hijack another issue for your problem. This thread deals with using pysmb with urllib which is not relevant to your issue.

It will be easier to attach the packet capture of the network traffic, so that we can study the parameters that are transmitted between the server and client during the negotiation.

DjesLoc commented 3 years ago

Sorry for the wrong post, i created a new issue.