无法通过HTTPS连接到Windows ServiceBus

时间:2013-04-26 17:08:53

标签: c# .net windows azure servicebus

我尝试使用HTTPS连接到Windows服务总线。这是我的应用配置设置:

  <appSettings>
  <add key="Microsoft.ServiceBus.ConnectionString" value="Endpoint=https://example-service.servicebus.windows.net/;SharedSecretIssuer=owner;SharedSecretValue=example-shared-secret-value"/>
  </appSettings>

以下是尝试创建连接的代码:

return SubscriptionClient.CreateFromConnectionString(ConnectionString, RequestTopicName,
                                                                 SubscriptionName, ReceiveMode.ReceiveAndDelete);

然而,它无效,抛出此错误:

  

无法使用连接字符串创建MessagingFactory。提供的URI方案&#39; https&#39;是无效的;预期&#39; sb&#39;。请参阅内部异常了解详细信检查连接字符串,然后重试。有关详细信息,请参阅http://go.microsoft.com/fwlink/?LinkID=249089

内在的例外:

提供的URI方案&#39; https&#39;是无效的;预期&#39; sb&#39;。在Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessagingFactory..ctor(IEnumerable 1 baseAddresses, NetMessagingTransportSettings settings) at Microsoft.ServiceBus.Messaging.NetMessagingTransportSettings.Microsoft.ServiceBus.Messaging.ITransportSettings.BeginCreateFactory(IEnumerable 1 physicalUriAddresses,AsyncCallback回调,对象状态)    在Microsoft.ServiceBus.Messaging.MessagingFactorySettings.OnBeginCreateFactory(IEnumerable 1 uriAddresses, AsyncCallback callback, Object state) at Microsoft.ServiceBus.Messaging.MessagingFactorySettings.BeginCreateFactory(IEnumerable 1 uriAddresses,AsyncCallback callback,Object state)    在Microsoft.ServiceBus.Messaging.MessagingFactory.CreateMessagingFactoryAsyncResult..ctor(MessagingFactorySettings设置,IEnumerable 1 addresses, TimeSpan timeout, AsyncCallback callback, Object state) at Microsoft.ServiceBus.Messaging.MessagingFactory.BeginCreate(IEnumerable 1地址,MessagingFactorySettings factorySettings,TimeSpan超时,AsyncCallback回调,对象状态)    在Microsoft.ServiceBus.Messaging.MessagingFactory.BeginCreate(IEnumerable 1 addresses, MessagingFactorySettings factorySettings, AsyncCallback callback, Object state) at Microsoft.ServiceBus.Messaging.MessagingFactory.BeginCreate(IEnumerable 1个地址,TokenProvider tokenProvider,AsyncCallback回调,对象状态)    在Microsoft.ServiceBus.Messaging.MessagingFactory.Create(IEnumerable 1 addresses, TokenProvider tokenProvider) at Microsoft.ServiceBus.Messaging.Configuration.KeyValueConfigurationManager.CreateFactory(IEnumerable 1个端点,IEnumerable`1 stsEndpoints,String operationTimeout,String issuerName,String issuerKey,String domain,String user,SecureString password)

如果我更改连接字符串以使用 sb .example-service.servicebus.windows.net而不是 https .example-service.servicebus.windows.net会工作,但我真的需要使用HTTPS而不是SB。

客户期待的任何想法&#39; sb&#39 ;?如何配置客户端以使用&#39; https&#39;。

1 个答案:

答案 0 :(得分:0)

以下是解决方案:将连接字符串的“https”部分更改回“sb”,即必须为“sb”。现在添加以下代码:

ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http;