none
wcf 捕捉到 TimeoutExeption (请求操作在配置的超时(00:01:00)内未收到回复) RRS feed

  • 问题

  • 发送到 http://192.168.1.219:9100/ 的请求操作在配置的超时(00:01:00)内未收到回复。分配给该操作的时间可能是更长超时的一部分。这可能由于服务仍在处理操作或服务无法发送回复消息。请考虑增加操作超时(将通道/代理转换为 IContextChannel 并设置 OperationTimeout 属性)并确保服务能够连接到客户端。

     

    请问一个这我要怎么解决? 要用到Isoneway吗?CallBackContract?


    认真学习,不耻下问.^_^
    2011年7月11日 5:09

答案


  • Hi,

    你可以在客户端代码中为代理配置OperationTimeout属性的值,该配置不同于其它的配置(例如:SendTimeout,ReceiveTimeout等等).在调用操作方法之前,在WCF客户端须将代理类型转换为IContextChannel。

    ((IContextChannel)client.InnerChannel).OperationTimeout = new TimeSpan(0,0,240);

    同样增加RecieveTimeout的值。

    如果是传输大文件的话,你须要考虑在客户端绑定属性中增大maxBufferSize、maxReceivedMessageSize、maxBufferPoolSize的值。

    如:
    maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647"

    你可以在服务端enable WCF Tracing查看详细的异常信息.


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework
    2011年7月15日 2:05
    版主

全部回复

  • /////////////////////服务契约/////////////////
    [ServiceContract(Namespace = "www.wally.com.cn/ICreateFactory_Contract", Name = "ICreateFactory_Contract")]
      [ServiceKnownType(typeof(GASQLReturnData))]
      public interface ICreateFactory
      {
        [OperationContract(Name = "ObjFactory_Contract", Action = "www.wally.com.cn/ICreateFactory_Contract/ObjFactory_Contract", ReplyAction = "www.wally.com.cn/ICreateFactory_Contract/ObjFactory_Contract")]
        GASQLReturnData ObjFactory(object factory, string MethodName, object[] param);
      }
      //public interface ICallBack
      //{
      //  [OperationContract(IsOneWay=true)]
      //  void CreateFactory(GASQLReturnData ret);
      //}
    //////////////////end servicecontract////////////
    
    ///////////实现服务契约类///////////
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, UseSynchronizationContext = false)]
      public class Services :ICreateFactory
      {
    
        public GASQLReturnData ObjFactory(object factory, string MethodName, object[] param)
        {
          
          GAFramework.GASQLReturnData ret = null;
          try
          {
            ret = new GASQLReturnData();
           ret=(GASQLReturnData)factory.GetType().InvokeMember(MethodName, BindingFlags.InvokeMethod, null, factory, new object[] { param });
    
          }
          catch (Exception ex)
          {
            Form1.WriteLog(ex.Message, "实例操作时 (WallySoft.ServiceContract.Services类里的GASQLReturnData方法)");
          }
          return ret;
        }
      }
    ///////////////////end ///////////////
    
    //说明一下:GASQLReturnData(返回这个类型)是我自定义的类代码如下:
    [DataContract]
      public class GASQLReturnData
      {
        private GASQLErrorInfo err = new GASQLErrorInfo();
        private DataTable dt = new DataTable();
        [DataMember(Order=1,IsRequired=false,Name="error_DataMember")]
        public GASQLErrorInfo error { get { return this.err; } set { this.err = value; } }
        [DataMember(Order = 2, IsRequired = false, Name = "Table_Member")]
        public DataTable Table
        {
          get
          {
            dt.TableName = "MyTable";
            return this.dt;
          }
          set
          {
            dt.TableName = "MyTable";
            this.dt = value;
          }
        }
    
        public GASQLReturnData()
        {
          error = new GASQLErrorInfo();
          Table = new DataTable();
          Table.TableName = "MyTable";
        }
      }
    
      [DataContract]
      public class GASQLErrorInfo
      {
        private string info = "";
        private int level = 0;
        private string possition = "";
        [DataMember(Order = 0, IsRequired = false, Name = "Info_DataMember")]
        public string Info { get { return this.info; } set { this.info = value; } }
        [DataMember(Order = 1, IsRequired = false, Name = "Level_DataMember")]
        public int Level { get { return this.level; } set { this.level = value; } }
        [DataMember(Order = 2, IsRequired = false, Name = "Possition_DataMember")]
        public string Possition { get { return this.possition; } set { this.possition = value; } }
    
        public GASQLErrorInfo()
        {
          Info = "";
          Level = 0;
          Possition = "";
        }
      }
    
    


    认真学习,不耻下问.^_^
    2011年7月11日 5:12

  • Hi,

    你可以在客户端代码中为代理配置OperationTimeout属性的值,该配置不同于其它的配置(例如:SendTimeout,ReceiveTimeout等等).在调用操作方法之前,在WCF客户端须将代理类型转换为IContextChannel。

    ((IContextChannel)client.InnerChannel).OperationTimeout = new TimeSpan(0,0,240);

    同样增加RecieveTimeout的值。

    如果是传输大文件的话,你须要考虑在客户端绑定属性中增大maxBufferSize、maxReceivedMessageSize、maxBufferPoolSize的值。

    如:
    maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647"

    你可以在服务端enable WCF Tracing查看详细的异常信息.


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework
    2011年7月15日 2:05
    版主