Тайм-аут канала запроса истек при ожидании ответа после 00:00:59.
-
10-12-2019 - |
Вопрос
Я пишу очень простой веб-сервис SharePoint.Я тестировал небольшую библиотеку 2010 года, и она каждый раз работает нормально.
Проблема возникает с сервером MOSS 2007, где библиотека очень большая.Я использую .Net 3.5, и с тремя строками кода я случайно получаю сообщение об ошибке. Тайм-аут канала запроса истек при ожидании ответа после 00:00:59.Если я увеличиваю тайм-аут, то все равно случайно я получаю ошибку, Базовое соединение было закрыто:Соединение было неожиданно закрыто.
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();
Я понятия не имею, почему случайно время ожидания истекает и ломается, на сервере проблем нет.У меня есть конструктор U2U CAML, и с его помощью я могу безостановочно выполнять запросы и мгновенно получать результаты.
Я думаю, что что-то не так в моем app.config или что-то, что мне нужно установить на стороне клиента.
Мой app.config имеет настройку ниже:
<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>
И
<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>
Я получаю ошибку ниже, когда меняю все время на 10 минут.И снова это случайный.
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
Решение 2
Я исправил проблему, но не уверен, почему это произошло, возможно, какой-нибудь эксперт может прокомментировать.
Решение заключалось в том, что вместо добавления в качестве ссылки на службу я добавил ее в качестве веб-ссылки, и это сработало.
Мои предположения по причинам ниже,
- Либо MOSS 2007 не нравится прокси-клиент, созданный по ссылке на сервис.
- В моей сети есть два приложения с одинаковым именем в разных доменах, хотя я использовал полное имя в ссылке на службу, поэтому это не должно быть причиной
Спасибо
Другие советы
Измените следующее:
closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00"
К:
closeTimeout="00:10:00" openTimeout="00:10:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00"