0
votes

I am trying to create a QueueClient and increase its timeout from the default of 60 seconds. When I create the client from the Connectionstring it works fine but I am unable to adjust the time. When I create the client using the factory See code below I get the following timeout exception. Can anyone tell me what I have missed out or just not done.

{"The request has timed out after 00:00:00 milliseconds. The successful completion of the request cannot be determined. Additional queries should be made to determine whether or not the operation has succeeded."}

Connection string that works Endpoint=sb://xxxx.servicebus.windows.net/;SharedAccessKeyName=policy;SharedAccessKey=key

Code:

MessagingFactorySettings settings = new MessagingFactorySettings
      {
        OperationTimeout = TimeSpan.FromSeconds(120),
        TokenProvider = TokenProvider.CreateSharedSecretTokenProvider("policy", "key")
      };

      var address = ServiceBusEnvironment.CreateServiceUri("sb", "xxxx.servicebus.windows.net", string.Empty);

      var messagingFactory = MessagingFactory.Create(address, settings);

      QueueClient result = messagingFactory.CreateQueueClient(queueName);

      result.RetryPolicy = new RetryExponential(TimeSpan.Zero, TimeSpan.FromMilliseconds(1000), 5);
      return result;
1

1 Answers

1
votes

are you using ACS or SAS keys? From your connection string, it looks like SAS, so you probably want to use CreateSharedSecretTokenProvider instead. As in

TokenProvider credentials = TokenProvider.CreateSharedAccessSignatureTokenProvider(sasKeyName,sasKeyValue);