简体   繁体   English

携带大数据时WCF套接字超时异常

[英]WCF Socket Timeout Exception while carrying large data

I am working newly on webservice WCF, and I have been assigned a responsibility to test the webservice in case of large data. 我正在研究Web服务WCF,在分配大数据的情况下,我被指派负责测试Web服务。 So, through Entity Object I am carrying approx. 因此,通过Entity Object我可以携带大约。 of 16000+ records, but my code is throwing exception like: 16000多个记录,但是我的代码抛出异常,例如:

The socket connection was aborted. 套接字连接已中止。 This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. 这可能是由于处理您的消息时出错,远程主机超出了接收超时或潜在的网络资源问题引起的。 Local socket timeout was '00:24:59.9989991'. 本地套接字超时为“ 00:24:59.9989991”。

Although I have increased the Socket Timeout from 5 To 25 in my App.Config and Web.Config files, but still there is the same error. 尽管我将App.Config and Web.Config文件中的Socket Timeout5增加到25 ,但是仍然存在相同的错误。 This made me believe that there must be large data issue. 这使我相信必须存在大数据问题。

App.Config 应用配置

<bindings>  
  <netTcpBinding>  
    <binding name="tcpBinding"  
              maxBufferSize="2147483647"  
              maxReceivedMessageSize="2147483647"  
              maxBufferPoolSize="2147483647"  
             receiveTimeout="00:06:00" sendTimeout="00:06:00" >  
      <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" />  
      <security mode="None" />  
    </binding>  
  </netTcpBinding>  
  <webHttpBinding>  
    <binding name="RESTBinding"  
              maxBufferSize="2147483647"  
              maxReceivedMessageSize="2147483647"  
              maxBufferPoolSize="2147483647"  
             receiveTimeout="00:06:00" sendTimeout="00:06:00" >  
      <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" />  
      <security mode="None" />  
    </binding>  
  </webHttpBinding>  
</bindings>  

cs file CS文件

userObject = client.GetAll().ToList();

And, GetALL() has this definition: 而且, GetALL()具有以下定义:

var result = (from user in entity.User select user).ToList();
    return result;

And, the above code returns 16000+ records, but due to which webservice is giving exception. 并且,上面的代码返回16000多个记录,但是由于该Web服务给出异常。 I have done R&D on the topic from the net but don't find any useful answer, can anyone suggest me what should I do. 我已经从网上进行了有关该主题的研发,但是找不到任何有用的答案,有人可以建议我该怎么做。

明智的选择是将大数据分成较小的程序包。

Modify the API to "page" the results. 修改API以“分页”结果。 In other words, instead of GetALL() expose Get(int start, int end) and have the user go through them a chunk at a time. 换句话说,代替GetALL()公开Get(int start, int end)并让用户一次遍历它们。 Your code in GetALL would change to something like: 您在GetALL代码GetALL改为:

var result = (from user in entity.User select user).Skip(start).Take(end-start).ToList();
    return result;

It's also a nicer thing to do for your users so you don't overwhelm them with too much data. 对您的用户来说,这也是一件更好的事情,这样您就不会因过多的数据而使他们不知所措。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM