简体   繁体   中英

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. So, through Entity Object I am carrying approx. of 16000+ records, but my code is throwing exception like:

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'.

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. 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

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

And, GetALL() has this definition:

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. 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. In other words, instead of GetALL() expose Get(int start, int end) and have the user go through them a chunk at a time. Your code in GetALL would change to something like:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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