我已经为具有默认命名空间的Windows Server 1.1(非Azure服务总线)安装了Service Bus。 我从中下载了样本 http://code.msdn.microsoft.com/windowsazure/Relayed-Messaging-Bindings-ca039161 并更改以下代码以生成令牌。
var machineName = Dns.GetHostEntry(string.Empty).HostName;
var networkCredential = new NetworkCredential(WindowsUsername, WindowsPassword, WindowsDomain);
string serviceNamespace = "ServiceBusDefaultNamespace";
// The TransportClientEndpointBehavior specifies the Service Bus credentials for a particular endpoint
var stsUris = new List<Uri> { new Uri(string.Format(CultureInfo.InvariantCulture, "https://{0}:9355/", machineName)) };
TransportClientEndpointBehavior relayCredentials = new TransportClientEndpointBehavior
{
TokenProvider = TokenProvider.CreateOAuthTokenProvider(stsUris, networkCredential)
};
//TransportClientEndpointBehavior relayCredentials = new TransportClientEndpointBehavior();
//relayCredentials.TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issuerName, issuerSecret);
Uri address = ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespace, "HelloService");
但它抛出以下错误 “无法通过TCP(9351,9352)或HTTP(80,443)到达servicebusdefaultnamespace.servicebus.windows.net”
我也尝试过使用BasicHTTPRelayBinding的相同示例,但这不起作用。
我是否需要为中继绑定执行其他配置 请建议!!!
提前致谢。
答案 0 :(得分:1)
目前,Service Bus 1.1 for Windows Server上没有Service Bus Relay功能。它仅在Azure Service Bus中可用。