首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WCF ServiceHost关闭操作超时

WCF ServiceHost关闭操作超时
EN

Stack Overflow用户
提问于 2015-04-07 18:20:59
回答 1查看 1.2K关注 0票数 0

我有一个巨大的超时问题,我不知道如何解决它!我使用windows服务客户端通过HTTPS连接到WCF服务。

我看过这个:http://blogs.msdn.com/b/hongmeig/archive/2010/03/06/timeouts-in-wcf-and-their-default-values.aspx

服务器端生成的错误

ServiceHost关闭操作在00:00:10之后超时。这可能是因为客户端未能在所需时间内关闭会话通道。分配给此操作的时间可能是较长超时的一部分。

在客户端生成的错误:

代码语言:javascript
复制
System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.

Server stack trace: 
   at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.System.IDisposable.Dispose()

这是我对WCF服务的绑定:

代码语言:javascript
复制
  <bindings>
    <wsHttpBinding>
      <binding name="Binding1" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:10:00">
        <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="true" />
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" />
        <security mode="TransportWithMessageCredential">
          <message clientCredentialType="UserName" />
        </security>
      </binding>
    </wsHttpBinding>
  </bindings>

这是代码客户端:

代码语言:javascript
复制
        wsHttpBinding = new WSHttpBinding(SecurityMode.TransportWithMessageCredential)
       {
           CloseTimeout = new TimeSpan(0, 0, 10, 0),
           OpenTimeout = new TimeSpan(0, 0, 10, 0),
           ReceiveTimeout = new TimeSpan(0, 10, 0, 0),
           SendTimeout = new TimeSpan(0, 0, 10, 0),
           TransactionFlow = false,
           MaxBufferPoolSize = 524288,
           MaxReceivedMessageSize = 2147483647,
           ReaderQuotas =
           {
               MaxDepth = 128,
               MaxStringContentLength = int.MaxValue,
               MaxArrayLength = 2147483647,
               MaxBytesPerRead = 16384,
               MaxNameTableCharCount = 16384
           }
       };

        wsHttpBinding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;

        wsHttpBinding.ReliableSession.Ordered = true;
        wsHttpBinding.ReliableSession.InactivityTimeout = new TimeSpan(0, 0, 10, 0);
        wsHttpBinding.ReliableSession.Enabled = true;
        Ednpoint = new EndpointAddress(new Uri(URL));

        myChannelFactory = new ChannelFactory<IPoint>(wsHttpBinding, Ednpoint);
        myChannelFactory.Endpoint.Contract.SessionMode = SessionMode.Allowed;

        ClientCredentials cc = myChannelFactory.Endpoint.Behaviors.Find<ClientCredentials>();

        cc.UserName.UserName = usr;
        cc.UserName.Password = pass;
        myChannelFactory.CreateChannel();

我使用这段代码发送这样的数据:

代码语言:javascript
复制
            using (IClientChannel client = (IClientChannel)myChannelFactory.CreateChannel())
            {
                client.OperationTimeout = TimeSpan.FromMinutes(10);
                IPoint wcfClient1 = (IPoint)client;
                for (int start = startpos; start < totalSize; start += size)
                {
                    List<Point> send = r.Skip(start).Take(size).ToList();
                    xreturn = wcfClient1.Update(send);
                    counter += 1;
                }
            }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-23 11:56:34

我已经解决了应用程序池一直在宿主服务器上重新启动的问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29498459

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档