hierynomus / smbj

Server Message Block (SMB2, SMB3) implementation in Java
Other
721 stars 179 forks source link

[Discussion] SMB Server not granting credits #270

Open skhare-r7 opened 6 years ago

skhare-r7 commented 6 years ago

Hello

I'm running a series of calls using SMBJ on a server, and eventually I'm hitting this exception:

Exception: com.hierynomus.smbj.common.SMBRuntimeException: Not enough credits (0 available) to hand out 1 sequence numbers

Any ideas what is going on here? Have you encountered anything like this in your testing?

hierynomus commented 6 years ago

Have not encountered this. From what you describe it seems that windows has some artificial limit in the total amount of credits that are granted to a single client. Can you check whether it always halts at exactly the same amount of total credits?

skhare-r7 commented 6 years ago

I don't believe it is a total number of credits issue, since I've not been able to reproduce this by flooding requests in a loop. This might be some limitation on the Windows side. For now, it seems the only possible workaround is to reconnect the session.

hierynomus commented 6 years ago

Do you get this with all Windows versions? Can you submit a reproduction test case, which we can run?

hierynomus commented 6 years ago

@skhare-r7 Any update here? I did indeed mean that there might be an artificial limit on the windows (remote) side, not in SMBJ.

smb311 commented 5 years ago

Hi @hierynomus @skhare-r7 did you ever make any progress with this? I have seen this happening in production systems (not SMBJ) and am wondering if anyone ever got some info from the Windows team about this issue.

hierynomus commented 5 years ago

@smb311 If you've got more info I'd be happy to hear it, but I have not seen this occur myself unfortunately.

But from what you say, you also see this appearing without using smbj?

ErwanLegrand commented 3 years ago

I have seen this happening with Samba's smbclient.

According to the specs, the server must make sure the clients' credits do not drop to zero: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/2e366edb-b006-47e7-aa94-ef6f71043ced

Thus, this looks like a server bug. Now, one might wonder why MS clients do not appear to trigger it.

skpatro93 commented 2 years ago

@hierynomus @skhare-r7 is this issue resolved as I am also facing this issue.

rokkakasu commented 2 years ago

Hi santhosh,

To an Smb share you can open only limited number of connections at a time. Not granting credit is a warning you can ignore. Once the previous connections are closed Smb server will allow new connection.

Try to reduce the frequency of opening connections. Issue is not with smbj library but with the Smb server you have.

Thanks R Ramarajan

On Tue, 5 Jul, 2022, 11:25 am santosh kumar, @.***> wrote:

@hierynomus https://github.com/hierynomus @skhare-r7 https://github.com/skhare-r7 is this issue resolved as I am also facing this issue.

— Reply to this email directly, view it on GitHub https://github.com/hierynomus/smbj/issues/270#issuecomment-1174646194, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIJCEGSIMDHCW64QNZ44J2TVSPE6RANCNFSM4EI5QGTA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

zacharybest commented 8 months ago

Was doing some testing using a MuleSoft SMB connector, which uses SMBJ.

In working with infrastructure, we found that a smart firewall was interpreting the traffic as a DDOS attack. In this case, the traffic would be blocked, but the error we were receiving was Not enough credits (0 available) to hand out 1 sequence numbers

akshay-pokle commented 6 months ago

Thanks @zacharybest, worked for me. One of the firewalls was blocking the requests interpreting the traffic as a DDOS attack. Had to add the Mule CIDR range as allowed IPs in the firewall.

zacharybest commented 6 months ago

Thanks @akshay-pokle for the comment. I forgot I posted here and should probably post an update. I am glad it worked out for you!

In our situation, while the firewall was confirmed to reproduce the issue, the firewall was not the cause of the intermittent issue we were experiencing. Ultimately, we decided to pursue an alternative to SMB and I am no longer looking into the cause.

For anyone deciding to pursue this further, a takeaway is that this credit message can occur when no communication with the server is occurring. For example, firewalls blocking the communication.

While I'm no longer pursuing this issue, the OP states the issue can be reproduced by sending a high volume of requests. Firewalls are confirmed to reproduce it (and smart firewalls can potentially view a high volume of requests as DDOS or some other threat), but given recreation scenario, I'd guess it could also occur in other situations where internal banked credits are consumed, while at the same time an issue occurs impacting the application's ability to communicate with the smb server. Ex: app maxing available connections, broken socket, etc.