Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am writing a very basic SharePoint webservice. I tested against 2010 small library and it works just fine every time.

Issue comes with MOSS 2007 server where a library is very big. I am using .Net 3.5 and with just below three lines of code, randomly I get error, The request channel timed out while waiting for a reply after 00:00:59. If I increase timeout then still randomly I get error, The underlying connection was closed: The connection was closed unexpectedly.

ListsSoapClient client = new ListsSoapClient();
        client.ClientCredentials.Windows.ClientCredential 
= System.Net.CredentialCache.DefaultNetworkCredentials;
client.ClientCredentials.Windows.AllowedImpersonationLevel 
=   System.Security.Principal.TokenImpersonationLevel.Impersonation;
XmlElement listCollection = client.GetListCollection();

I have no clue why randomly it times out and breaks, server has no issues. I have U2U CAML builder and using it I can nonstop execute query and get results back instantly.

I think there is something wrong at my app.config or something I need to set in client side.

My app.config has below setting,

        <binding name="ListsSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
        receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
        bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
        maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
        useDefaultWebProxy="true">
        <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Ntlm"/>
        <message clientCredentialType="UserName" algorithmSuite="Default"/>
        </security>
        <readerQuotas maxDepth="32" maxStringContentLength="8192" 
        maxArrayLength="16384"
        maxBytesPerRead="4096" maxNameTableCharCount="16384" />                 
        </binding>

And

  <client>
    <endpoint address="http://ap/AP/_vti_bin/Lists.asmx" binding="basicHttpBinding"
      bindingConfiguration="ListsSoap" contract="SharePointListWebService.ListsSoap"
      name="ListsSoap" />
    <endpoint address="http://ap/AP/_vti_bin/Copy.asmx" binding="basicHttpBinding"
      bindingConfiguration="CopySoap" contract="SharePointCopyWebService.CopySoap"
      name="CopySoap" />
  </client>

I receive below error when I chnage all time out to 10 minute. And again, its random.

   Unhandled Exception: System.ServiceModel.CommunicationException: The underlying
   connection was closed: A connection that was expected to be kept alive was close
   d by the server. ---> System.Net.WebException: The underlying connection was clo
   sed: A connection that was expected to be kept alive was closed by the server.
      at System.Net.HttpWebRequest.GetResponse()
      at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpCha
   nnelRequest.WaitForReply(TimeSpan timeout)
      --- End of inner exception stack trace ---

   Server stack trace:
      at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebExc
   eption(WebException webException, HttpWebRequest request, HttpAbortReason abortR
          eason)
      at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpCha
   nnelRequest.WaitForReply(TimeSpan timeout)
      at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeS
   pan timeout)
      at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message messag
   e, TimeSpan timeout)
      at System.ServiceModel.Channels.ServiceChannel.Call(String action,               Boolean        on       
   eway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan tim
   eout)
      at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean on
   eway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
      at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCall
   Message methodCall, ProxyOperationRuntime operation)
      at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

   Exception rethrown at [0]:
      at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage req
   Msg, IMessage retMsg)
      at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgDa
   ta, Int32 type)
      at FetchInvoicesFromSharePointForMaximo.SharePointListWebService.ListsSoap.Ge
   tListCollection(GetListCollectionRequest request)
      at FetchInvoicesFromSharePointForMaximo.SharePointListWebService.ListsSoapCli
   ent.FetchInvoicesFromSharePointForMaximo.SharePointListWebService.ListsSoap.GetL
   istCollection(GetListCollectionRequest request) in C:\FetchInvoicesFromSharePoin
   tForMaximo\FetchInvoicesFromSharePointForMaximo\Service References\SharePointLis
   tWebService\Reference.cs:line 2267
      at FetchInvoicesFromSharePointForMaximo.SharePointListWebService.ListsSoapCli
   ent.GetListCollection() in C:\FetchInvoicesFromSharePointForMaximo\FetchInvoices
   FromSharePointForMaximo\Service References\SharePointListWebService\Reference.cs
   :line 2273
      at FetchInvoicesFromSharePointForMaximo.Program.Main(String[] args) in C:\Fet
   chInvoicesFromSharePointForMaximo\FetchInvoicesFromSharePointForMaximo\Program.c
   s:line 32
share|improve this question

2 Answers 2

Change the following:

closeTimeout="00:01:00" openTimeout="00:01:00"
        receiveTimeout="00:10:00" sendTimeout="00:01:00"

To:

closeTimeout="00:10:00" openTimeout="00:10:00"
        receiveTimeout="00:10:00" sendTimeout="00:10:00"
share|improve this answer
1  
As I mentioned if I increase timeout value, it gives The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. –  abhishek shah Mar 5 '13 at 18:13
    
Did you use the copysoap endpoint oder the listsoap? Because they have different bindings... –  Sascha Jan 13 at 18:21

I fixed issue but I am not sure hwy this happened may be some Expert can comment.

Solution was, instead of adding as a service reference I added as web reference and it did trick.

My assumptions for reasons are below,

  1. Either MOSS 2007 does not like proxy client created by service reference
  2. In my network we have two application with same name in different domain, though I was using fully qualified name in service reference so this should not be cause

Thanks

share|improve this answer
1  
please do not forget to mark your post as answer. –  TempaC Nov 8 '13 at 12:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.