RT,系统是windows 2003 ,服务器端是web,客户端是winform,不使用服务引用,服务器端打开wcf服务正常的情况下,客户端去连接服务器端出现:套接字连接已中止。这可能是由于处理消息时出错或远程主机超过接收超时或者潜在的网络资源问题导致的。本地套接字超时是“00:01:29.9709963”。在本机的WIN7和XP 系统测试没有问题,想请问各位一般出现这个异常要如何解决,谢谢
附上WCF配置代码:
服务器:
NetTcpBinding myBinding = new NetTcpBinding();
                myBinding.Security.Mode = SecurityMode.None;
                myBinding.MaxReceivedMessageSize = 2147483647;
                myBinding.TransferMode = TransferMode.Streamed;
                myBinding.ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas();
                myBinding.ReaderQuotas.MaxArrayLength = int.MaxValue;
                myBinding.ReaderQuotas.MaxStringContentLength = int.MaxValue;                Uri baseAddress = new Uri("net.tcp://" + ip + ":9999/WCFService/");
                myServiceHost = new ServiceHost(typeof(Service), baseAddress);
                ServiceEndpoint myServiceEndpoint = myServiceHost.AddServiceEndpoint
                    (typeof(IService), myBinding, "GetIdentity");
                try
                {
                    myServiceHost.Open();
                    if (myServiceHost.State == CommunicationState.Opened)
                        return true;
                    else
                        return false;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
客户端:
                    
                    NetTcpBinding binding = new NetTcpBinding();
                    binding.Security.Mode = SecurityMode.None;
                    binding.TransferMode = TransferMode.Streamed;
                    binding.MaxBufferPoolSize = int.MaxValue;
                    binding.MaxBufferSize = int.MaxValue;
                    binding.MaxReceivedMessageSize = 2147483647;
                    binding.ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas();
                    binding.ReaderQuotas.MaxArrayLength = int.MaxValue;
                    binding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
                    binding.ReaderQuotas.MaxBytesPerRead = int.MaxValue;
                    binding.OpenTimeout = new TimeSpan(0, 1, 30);
                    binding.ReceiveTimeout = new TimeSpan(0, 1, 30);
                    binding.SendTimeout = new TimeSpan(0, 1, 30);                    //利用通道创建客户端代理
                    DCF = new ChannelFactory<IService>(binding, new EndpointAddress("net.tcp://" + ip + ":9999/WCFService/GetIdentity"));
                    _proxy = DCF.CreateChannel();
                    IContextChannel obj = _proxy as IContextChannel;//订阅消息
                    try
                    {
                        _proxy.isOnline();
                        isok = true;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }

解决方案 »

  1.   

    有可能是返回table必须指名tablename没有赋值。。
     
     DataTable dt = new DataTable();
               dt.TableName = "mrzhou";
      

  2.   

    也不是啦,在服务器端设定好WCF并打开连接后,仅仅只是去进行尝试连接操作,没有去查询数据库或者赋值datatable之类的
      

  3.   

    使用telnet这个端口,允许连接
      

  4.   

    问题出在这个地方:_proxy.isOnline();这个函数中并没有实现任何功能,只是用来测试连接是否成功
      

  5.   

    是不是没连上wcf啊?要是客户端可以调试的话,你也调试下,wcf服务上也设置个断点,看看走到那了没?
      

  6.   

    嗯,都可以调试,但服务器打开是成功的,客户端连接不成功。PS:在win7或者XP都可以运行完全没问题,而放到win2003才出现了这个问题
      

  7.   

    如何我将客户端                    binding.OpenTimeout = new TimeSpan(0, 1, 30);
                        binding.ReceiveTimeout = new TimeSpan(0, 1, 30);
                        binding.SendTimeout = new TimeSpan(0, 1, 30);这当中的事件调节的更长,客户端调试到_proxy.isOnline();就自动断开调试,也不会进入catch中
      

  8.   

    WCF的报错有时候很不靠谱。
    你检查一下你传输的对象以及它的属性是否有空值,特别是枚举是否有赋值。
    把这些空值都赋一个默认值试试。
      

  9.   

    难道是你传输的东西太多了?  
    加个这个试试吧,我也不知道咋弄了
            binding.CloseTimeout = new System.TimeSpan(0, 1, 30);
            
      

  10.   

    在你的服务类头上添加[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    将一般性的服务端错误返回给客户端,这样你客户端就知道是什么错误了,现在这情况是被你屏蔽了错误,所以根本无法分析错误原因。