gpt4 book ai didi

c# - Dynamics CRM 导致 CommunicationException

转载 作者:太空宇宙 更新时间:2023-11-03 13:57:13 24 4
gpt4 key购买 nike

我正在使用 MS Dynamics CRM api 从中获取数据(超过 5000 条记录)。

我正在使用基于 XML 的查询来获取数据

EntityCollection resultSet = _orgServiceProxy.RetrieveMultiple(new FetchExpression(query));

有时它会工作,但大多数时候它会抛出异常,从日志中,我得到了这么长的异常。

An error occurred while receiving the HTTP response to https://orgno.api.crm.dynamics.com/XRMServices/2011/Organization.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details. ---> System.ServiceModel.CommunicationException: An error occurred while receiving the HTTP response to https://orgno.api.crm.dynamics.com/XRMServices/2011/Organization.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count) at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.TlsStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.GetResponse() at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) --- End of inner exception stack trace

我不知道为什么会这样?

最佳答案

CRM 服务根本不喜欢在一个请求中检索大量数据。

我建议您使用分页 cookie 来按组检索您的记录。它应该可以解决您的问题并提高代码的性能。

你可以在 msdn 上找到一个很好的教程 here .

问候,

凯文

关于c# - Dynamics CRM 导致 CommunicationException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11771519/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com