简体   繁体   中英

Setting service bus queue timeout

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;

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM