jborean93 / smbprotocol

Python SMBv2 and v3 Client
MIT License
316 stars 73 forks source link

Multiple sessions on SMB windows/linux shares #231

Closed Alexinio97 closed 1 year ago

Alexinio97 commented 1 year ago

Hi, We get this error when we try to open multiple sessions to our windows share Received unexpected status from the server: No more connections can be made to this remote computer at this time because the computer has already accepted the maximum number of connections. (3221225680) STATUS_REQUEST_NOT_ACCEPTED: 0xc00000d0 I checked some of Microsoft documentation about SMB and it seems that the limit is 20. I'm not sure how to increase it yet. From what I've seen that this exception is not thrown somewhere in the code so it comes from SMB itself right? Did you stumble upon this limitation, is there any way to avoid this exception? Is there the same limit on Linux shares as well? This happens when we try to open multiple session in order to download some files.

jborean93 commented 1 year ago

Is there a reason that you are opening multiple sessions? You can have multiple concurrent operations for a single session/tree connect so you should only need one.

Alexinio97 commented 1 year ago

I am getting grpc requests from different threads so I'm opening a session for each thread. Should we share the session on all of them? It has the potential to be highly loaded and that's why we got into that exception.

jborean93 commented 1 year ago

There may be limits to the number of concurrent file opens you can have on a session/tree but unfortunately these are restrictions placed on the server. I would try and reuse the session and tree connects if you can to avoid unnecessary network calls.

Unfortunately the client is at the mercy of what the server allows. If you exceeds its limits you have to change the workflow.

Alexinio97 commented 1 year ago

Do you happen to know what should be changed on the server configuration ( samba on linux and smb on windows ) in order to increase this limit? I'm not sure what limits I have to set or if these limits are editable by any chance. Thank you!

jborean93 commented 1 year ago

Not sure sorry, just stop creating a session per open and reuse your session. The only reason to create a new session was if you wanted to authenticate as a different user.

Alexinio97 commented 1 year ago

Got it, thank you!