WCF net.tcp绑定服务消耗

时间:2012-06-09 07:40:33

标签: wcf

我有以下WCF客户端代码来使用WCF服务:

static void Main(string[] args)
        {
            IService1 vService;
            NetTcpBinding b = new NetTcpBinding();
            b.Security.Mode = SecurityMode.Message;
            b.Security.Message.ClientCredentialType = MessageCredentialType.Windows;

            EndpointAddress vEndPoint = new EndpointAddress("net.tcp://115.127.1.226/myservice/");
            ChannelFactory<IService1> cf = new ChannelFactory<IService1>(b, vEndPoint);

            vService = cf.CreateChannel();
            try
            {
                Console.WriteLine("Result from the system " + vService.HellowWorld());
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error Occured while connection establish to " + vEndPoint.Uri.ToString());
            }
            Console.ReadKey();

        }

当我在本地运行它时,它成功运行。 但是,当我尝试远程使用我的WCF服务时,任何人都建议发生异常 我怎么能解决这个问题?

我的例外消息是:

Could not connect to net.tcp://115.127.1.226/myservice/. The connection attempt lasted for a time span of 00:00:21.0282028. TCP error code 10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
115.127.1.226:808.

1 个答案:

答案 0 :(得分:-1)

尝试使用  ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http;