类型为#System; TimeoutException'的未处理异常发生在Microsoft.ServiceBus.dll中

时间:2015-01-21 14:22:34

标签: c# azure service

其他信息:请求在00:00:00毫秒后超时。无法确定请求的成功完成。应进行其他查询以确定操作是否成功。

我正在关注https://msdn.microsoft.com/en-us/library/azure/ee706736.aspx的教程,在运行控制台程序并输入我的访问信息后,我得到了上述异常。我将策略名称和访问密钥以及命名空间放在登录详细信息中,但似乎不起作用。

using System;
using System.ServiceModel;
using System.ServiceModel.Description;
using Microsoft.ServiceBus;
using Microsoft.ServiceBus.Description;

namespace Microsoft.ServiceBus.Samples
{
[ServiceContract(Name = "IEchoContract", Namespace = "http://samples.microsoft.com/ServiceModel/Relay/")]

public interface IEchoContract
{
    [OperationContract]
    String Echo(string text);
}

public interface IEchoChannel : IEchoContract, IClientChannel { };

[ServiceBehavior(Name = "EchoService", Namespace = "http://samples.microsoft.com/ServiceModel/Relay/")]

class EchoService : IEchoContract
{
    public string Echo(string text)
    {
        Console.WriteLine("Echoing: {0}", text);
        return text;
    }
}

class Program
{
    static void Main(string[] args)
    {

        ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.AutoDetect;



        Console.Write("Your Service Namespace: ");
        string serviceNamespace = Console.ReadLine();
        Console.Write("Your Issuer Name: ");
        string issuerName = Console.ReadLine();
        Console.Write("Your Issuer Secret: ");
        string issuerSecret = Console.ReadLine();

       // Create the credentials object for the endpoint.
        TransportClientEndpointBehavior sharedSecretServiceBusCredential = new TransportClientEndpointBehavior();
        sharedSecretServiceBusCredential.TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issuerName, issuerSecret);


        // Create the service URI based on the service namespace.
        Uri address = ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespace, "EchoService");

        // Create the service host reading the configuration.
        ServiceHost host = new ServiceHost(typeof(EchoService), address);

        // Create the ServiceRegistrySettings behavior for the endpoint.
        IEndpointBehavior serviceRegistrySettings = new ServiceRegistrySettings(DiscoveryType.Public);

        // Add the Service Bus credentials to all endpoints specified in configuration.
        foreach (ServiceEndpoint endpoint in host.Description.Endpoints)
        {
            endpoint.Behaviors.Add(serviceRegistrySettings);
            endpoint.Behaviors.Add(sharedSecretServiceBusCredential);
        }

        // Open the service.
        host.Open();

        Console.WriteLine("Service address: " + address);
        Console.WriteLine("Press [Enter] to exit");
        Console.ReadLine();

        // Close the service.
        host.Close();
    }
}

}

0 个答案:

没有答案