Closed Sparin closed 10 months ago
In all cases so far, "Not Enough Credits" was the result of misusing the client (e.g. sending requests in parallel, changing the library code, using a buggy server and etc.)
Tal
@TalAloni , the client implementation DOES NOT handle a situation where the remote host forcibly closes the connection. It completely ignores this scenario when sending a package. As a result, when the server is down, the client cannot proceed with any further commands, and it fails to report this to the user.
And please, take a look at the code example at least. There is no concurrent code or requests, no changing library, or using a buggy server from Microsoft.
I see your point
Thank you, a resolution for this issue was pushed to master.
Bug template from dotnet/runtime
Description
SMB2Client
throws aNot enough credits
exception due to no response from the server on previous commands.Reproduction steps
SMB2Client
Example code: https://github.com/Sparin/OutOfCredits
https://github.com/TalAloni/SMBLibrary/assets/7052869/8f2c72af-c47e-4f07-bfe7-54644402f7f7
Expected behaviour
The
SMB2Client
should be capable of resuming work after a network failure and restoration or notifying the user of the API about the need to perform certain actions, such as reconnecting, for example. If theNot enough credits
condition occurs, it MUST either proxySTATUS_INVALID_PARAMETER
from the server or request more credits from it.Actual behaviour
The
SMB2Client
is unable to proceed anyTrySendCommand(SMB2Command request)
and remains connected even if the connection is lost. It doesn't respectSocketException
with the messageAn existing connection was forcibly closed by the remote host.
Known Workarounds
Full reconnect with on
STATUS_INVALID_SMB
status or anException
with messageNot enough credits
, then setm_availableCredits
to default value (16) via reflection APIs. Or just create new SMB2Client and connect again.Configuration
Other information
According to [MS-SMB2] 3.2.4.1.2 Requesting Credits from the Server,
This implies that
SMB2Client
MUST NOT throw aNot enough credits
exception. Instead, it should request more credits when necessary. If such a condition occurs, it should provide additional information indicating an unrecoverable condition, and the user should either reconnect or report the issue to the server's provider, referencing [MS-SMB2] 3.3.1.2, which details the Algorithm for the Granting of CreditsAnd the last one is [MS-SMB2] 3.3.5.2.5 Verifying the Credit Charge and the Payload Size
This implies that the user of
SMB2Client
should expect the appropriate status as specified in the specifications and handle the situation accordingly. Alternatively, the client itself should handle the situation