0

I have just tried to upgrade to version 4.1.3 of serviceBus and now my SAS generated token's fail. I am using these tokens to connect with a WCF relay in servicebus.

The error I get is "Time-out interval must be less then 2^32-2"

The token's definitely work on the version 3.4.3.

When I generate the token I was calculating a timeToLive of between 1970 and the year 3000. I believe this is my issue as if I set this to a low value I can generate new tokens that work (10 days). This will not work for me because I need tokens that will not expire.

Does anyone now how the timeToLive works. What is the maximum value and if there is any work-around where I can continue to use my SAS tokens. They have been generated and are in the field - so re-generating them will be difficult.

The code I am using is below:

Dim TimeToLive = TimeSpan.FromDays(365) 'This will fail    
Dim serviceUri = ServiceBusEnvironment.CreateServiceUri("https",
     serviceNamespace,
     servicePath).ToString().Trim("/")

Dim sasKey As String = SharedAccessSignatureTokenProvider.GetSharedAccessSignature(
     SharedAccessKeyName,
     SharedAccessKeyPrimary,
     serviceUri,
     TimeToLive)

the generated sasKey will fail when it is used. if I set the TTL to 10 days it would work.

Thanks for your help

matvdl
  • 63
  • 4

2 Answers2

0

According to your description, I also created a test demo on my side. It works well.

I used WindowsAzure.ServiceBus 4.1.3.

enter image description here

My codes as below:

Sub Main()

    Dim serviceNamespace = " "
    Dim servicePath = " "
    Dim SharedAccessKeyName = " "
    Dim SharedAccessKeyPrimary = " "
    Dim TimeToLive = TimeSpan.FromDays(365) 'This will fail    
    Dim serviceUri = ServiceBusEnvironment.CreateServiceUri("https",
         serviceNamespace,
         servicePath).ToString().Trim("/")
    Dim sasKey As String = SharedAccessSignatureTokenProvider.GetSharedAccessSignature(
         SharedAccessKeyName,
         SharedAccessKeyPrimary,
         serviceUri,
         TimeToLive)
    Dim mfSettings As New MessagingFactorySettings()
    mfSettings.TransportType = TransportType.NetMessaging
    mfSettings.TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider(sasKey)
    Dim mf As MessagingFactory = MessagingFactory.Create("sb://serviceNamespace.servicebus.windows.net", mfSettings)
    ' Create Client
    Dim client As QueueClient = mf.CreateQueueClient(servicePath)

    Dim message = New BrokeredMessage("test")



    client.Send(message)

End Sub

Result:

I add eight messages to it.

enter image description here

Brando Zhang
  • 22,586
  • 6
  • 37
  • 65
0

You have connected a queue, if you were to connect a wcf relay you will find that it will not work.

See response from Microsoft I heard from Product team and they advised that this is a by-design behavior in version 4.1.3. The change was a decision from PM and Management team based on the understanding that SAS token should be periodically re-requested. However this is about to change again in the next release in which longer expiration time will be supported again. We regret not being able to provide you with a quick solution.

matvdl
  • 63
  • 4