Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

ActiveClientLinkManager throws ArgumentOutOfRangeException in SetRenewCbsTokenTimer. #672

Open
zlatanov opened this issue Mar 22, 2019 · 1 comment
Labels

Comments

@zlatanov
Copy link

Actual Behavior

ArgumentOutOfRangeException is thrown.
Number must be either non-negative and less than or equal to Int32.MaxValue or -1.
Parameter name: dueTime.

Call Stack:

Microsoft.Azure.ServiceBus.Amqp.ActiveClientLinkManager.ChangeRenewTimer(Microsoft.Azure.ServiceBus.Amqp.ActiveClientLinkObject activeClientLinkObject, System.TimeSpan dueTime) Line 149
Microsoft.Azure.ServiceBus.Amqp.ActiveClientLinkManager.SetRenewCbsTokenTimer(Microsoft.Azure.ServiceBus.Amqp.ActiveClientLinkObject activeClientLinkObject) Line 137
Microsoft.Azure.ServiceBus.Amqp.ActiveClientLinkManager.RenewCbsTokenAsync(Microsoft.Azure.ServiceBus.Amqp.ActiveClientLinkObject activeClientLinkObject) Line 111

void SetRenewCbsTokenTimer(ActiveClientLinkObject activeClientLinkObject)
{
if (activeClientLinkObject.AuthorizationValidUntilUtc < DateTime.UtcNow)
{
return;
}
var interval = activeClientLinkObject.AuthorizationValidUntilUtc.Subtract(DateTime.UtcNow) - ActiveClientLinkManager.TokenRefreshBuffer;
interval = TimeoutHelper.Min(interval, ActiveClientLinkManager.MaxTokenRefreshTime);
this.ChangeRenewTimer(activeClientLinkObject, interval);

The interval here becomes negative. ActiveClientLinkManager.TokenRefreshBuffer is 10 seconds according to the debugger. Because the refresh buffer is subtracted this makes line 128 incorrect - it doesn't take it into consideration.

Also I think that even if it wasn't subtracted, the code would still have issues because the DateTime.UtcNow is called twice, which could return different times which in turn makes the check on line 128 obsolete.

Versions

  • OS platform and version: Windows 10, 1803
  • .NET Version: NETCore 2.2
  • NuGet package version: 3.3
@axisc axisc added the bug label Apr 15, 2019
@axisc
Copy link

axisc commented Apr 15, 2019

@zlatanov - thanks for reporting this, we'll investigate and fix internally.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants